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



Jul 25, 2012, 11:07 AM
4 Posts

Bind Computed fields

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags: Bind Computed fields
  • Replies: 4
 Hi,
 
 I know how to bind a computed field to a document field. And I know how to use javascript to compute a computed field. But how do I do both?

Eg: When I give -- datasource.replaceitemvalue("Computed field name in form",getComponenet("javascript used to compute the computed field").getValue();
works fine.

But, If I use the same line 
datasource.replaceitemvalue("Computed field name 1",getComponenet("javascript used to compute the computed field").getValue();
datasource.replaceitemvalue("Computed field name 2",getComponenet("javascript used to compute the computed field").getValue();
.
.
.
datasource.replaceitemvalue("Computed field name 27",getComponenet("javascript used to compute the computed field").getValue();

for say 25+ computed fields in SSJS, the server is crashing.
  
Please advice on how to approach computed fields in XPages
Jul 29, 2012, 5:55 PM
586 Posts
Re: Bind Computed fields
I'm really not sure what you're trying to do.... I'd be interested to see some XML of what you're doing.  But it doesn't sound like you're actually "binding".
 
First "getComponent" is how it should be spelled.  not what you typed into the source.   
 
computed fields are usually "bound" to a document  field or to a scoped variable.  They're more for reading then writing.
 
If you want to set a value of a field in a document...  in the SAVE event you might do something like this
 
document1.replaceItemValue("fieldname", getComponent("idFieldName").getValue())
 
That should on save take the value of a control on your xpage - like an edit box and save it to a document. That edit box could be unbound...  or bound to a viewScope variable...
 
 
Jul 30, 2012, 5:35 AM
4 Posts
Re: Bind Computed fields
 Hi,

When I set a value of a field in a document...  in the SAVE event, as you mentioned for more fields  under SSJS,

document1.replaceItemValue("fieldname", getComponent("idFieldName").getValue()),

the server gets crashed. 
Jul 30, 2012, 1:15 PM
586 Posts
Re: Bind Computed fields
 Interesting...  
In the line you typed in you have a comma at the end instead of a semi-colon...  I assume that comma is not actually in your code and just forum typing... 
 
anyway...  i do this ALL THE TIME in querySaveDocument events and never have a problem.  Granted more often then not I'll pull information from a scoped variable rather then using getComponent...  but I have used getComponent before...   
 
for it to cause a server crash is really odd.  Try to make sure you're on 8.5.3 with at least FP1...  if for some reason you're on 8.5.0 well...  weird things happened back then... 
 
You might want to clean the project...  I'd even go as far to get a SIMPLE demo test working in a new database...  just to see if it's specific to that database for some reason. 
 
that's probably all I can suggest...  you might need to open a PMR with IBM as that should not cause the server to crash... 
Jul 31, 2012, 5:27 AM
4 Posts
Re: Bind Computed fields
 Thanks. Its a forum typo error.

In querysave event, there is only SSJS option available. Each time (on executing each line), it hits the server and there are chances of server going down.

I shall check on the other options. Possible, could you pls let me know, how to pull information from a scoped variable.

Eg: I have a computedField1 and write my computation in Javascript and set the value of a field in a document using,

document1.replaceItemValue("fieldname", getComponent("computedField1").getValue());

In this case, when I make use of scoped variable, where do I make the Javascript computation and set it to a scoped variable.

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