This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 12, 2012, 2:51 PM
26 Posts

Error with replaceItem

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role:
  • Tags:
  • Replies: 1
I have an SSJS button that executes the follwiing code:
 
var doc:NotesDoctument = document1.getDocument()
 doc.replaceItemValue("Status","Submitted")
doc.replaceItemValue("FormCreated",@Created)
doc.replaceItemValue("FormCreatedBy",@UserName)   
doc.replaceItemValue("AllAuthors","[Specialist]")   
item = doc.replaceItemValue("AllReaders","[Specialist]")
item.appendToTextList("[Global Reader]")
 
 
I am getting an error :
 
Error while executing JavaScript action expression
Script interpreter error, line=7, col=13: [TypeError] Exception occurred calling method NotesDocument.replaceItemValue(string, function) null
 
This is occurring on the line.:
 
doc.replaceItemValue("FormCreated",@Created)
 
 
If doc were null why didn't I get the error on the first  replaceItemValue?
 
 
Any idea what is going on here?
 
I have also tried 
 
 document1.replaceItemValue with the same results.
 
If I call doc.save or document1.save then it saves just  fine.   Just as long as I don't call replaceItemValue.
 
 
 
 
Mar 12, 2012, 9:43 PM
261 Posts
Re: Error with replaceItem
Bruce,
 
I see a couple of problems with your code:
 
- I don't know if you copy-pasted it, but the first line reads NotesDoctument instead of NotesDocument (notice the extra t)
 
- On the 3rd line you're trying to store the created date in the FormCreated field. First: if you want to use a (SSJS) @-function, you'll need to write it as @Created() (notice the parentheses), second, the @Created() function returns a java Date object. If you want to store a NotesDateTimeObject, you'll have to use:
 
doc.replaceItemValue( "FormCreated", session.createDateTime( @Created() ) );
 
- The 3rd line should read:
 
doc.replaceItemValue("FormCreatedBy",@UserName() );   
 
- Instead of 
 
item = doc.replaceItemValue("AllReaders","[Specialist]")
item.appendToTextList("[Global Reader]")
 
you could use:
 
doc.replaceItemValue("AllReaders", [ "[Specialist]", "[Global Reader]" ]) ;
 
(this creates the array containing the 2 roles and adds it to the AllReaders field
 
Good luck!
 
Mark
 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal