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



Oct 1, 2012, 11:05 PM
6 Posts
topic has been resolvedResolved

Computed fied value not displaying in view

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer,Administrator
  • Tags: Xpages,SSJS custom control computed field
  • Replies: 3
Hi!
 
Here is my website where the code resides: http://bit.ly/OJmanJ
 
I have a XPage form that has a computed field on it. The formula behind that is:  session.evaluate("@Unique").elementAt(0); (the data is bound using a scoped variable on Request to the field name CSI_ID)
When I preview the form in Firebug, I can see the @Evaluate is working. I am just unable to get a handle to it. I have a Save button with the code below. I do not get any errors, however, my CSI_ID is always "". 
When I open the document, I can see the value of CSI_ID on the document, it just does not get visible until I go into the client and force save it. I know there is something wrong with my code below, but I don't know what.
 
 
document1.save();
var x = document1.getElementById("CSI_ID").innerHTML
document1.replaceItemValue("CSI_ID", x);
document1.save();

This quirky behavior is visible on the website. When you "Submit a new CSI" and then click "Save". I also would like to close the document and get back to the "All Documents" view, when I cross this hurdle. I would really appreciate some help and guidance with what I am doing wrong with this.
 
Thank you so much in advance!
 
-Shabana.
 
Oct 2, 2012, 4:28 AM
366 Posts
Re: Computed fied value not displaying in view
It appears as if you are trying to combine SSJS and CSJS 
 
The following code will not execute as SSJS
 
document1.save();
var x = document1.getElementById("CSI_ID").innerHTML
document1.replaceItemValue("CSI_ID", x);
document1.save();
 
document1 represents the XPage document data source and does not have a getElementById method
 
to get the value of an element in ssjs just call 
 
var x = getComponent("CSI_ID").getValue();
 
to set the value use the setValue(variable); syntax 
 
to write to the backend document use the getDocument() method of the document1 global object. 
Oct 2, 2012, 2:46 PM
6 Posts
Re: Computed fied value not displaying in view
Paul, 
 
Thank You so much for your help! I was able to successfully resolve my issue and update the code. You can see it in action here:CSI Tracker Tool - Shabana Wollin -> Submit a new CSI.
I did not realize that I was mixing up the client-side vs SSJS.  My new code is included below. Do you have any suggestions on how I can close the document and get back to my "All Documents" view upon save from this code or would I need to use something else?
 
Revised Code: (Server Side JS for Save Button)

var doc:NotesDocument = document1.getDocument();

var x = getComponent("CSI_ID").getValue();

getComponent("CSI_ID").setValue(x);

doc.replaceItemValue("CSI_ID", x);

document1.save();

  Thanks once again!
Shabana. 
 
 
Oct 2, 2012, 5:24 PM
6 Posts
Re: Computed fied value not displaying in view
I got! I just used
context.redirectToPage("viewAllDocuments");
 
Thanks! :)

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