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



May 30, 2011, 10:07 PM
27 Posts

Javascript Code - Update to Document Field

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: javascript
  • Replies: 1
 This seems to work, however as a newbie to Lotus Notes I suspect there may be a better way of doing this.  What I am doing is appending a string to a single field in a document and saving it.  Does this look correct?
 
var name = context.getUser().getCommonName();
if(/^CN=/.test(name)) name = name.substr(3,name.indexOf('/')-3);
var historyMessage += name+" has made an update";
var history = doc.getItemValue('OneHistory');
history.push(historyMessage);
doc.replaceItemValue('OneHistory',history);
doc.save();
 
Is there a way of saving just the field or do you have to doc.save()? 
 
Thanks in advance for any advice!
 
May 31, 2011, 8:22 AM
33 Posts
Re: Javascript Code - Update to Document Field
Hi, you have to save the whole doc every time.
About the way you append value to a multivalue field does this thing works?

history.push(historyMessage); 
 
Because by calling doc.getItemValue() one get a instance of java.util.Vector and there is no method named push.
Even if it works I suggest to use the add() method a specify the type of history variable.
 
var history:java.util.Vector = doc.getItemValue('OneHistory'); 
history.add(historyMessage); 

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