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, 2012, 12:37 PM
8 Posts
topic has been resolvedResolved

session.evaluate Fails if the formula has a space

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role:
  • Tags: session.evaluate formula
  • Replies: 4
 I am having a problem with using  session.evaluate at a document level.
The formula works if there is no space, but if there is a space the formula gets cut off at the space, and an NULL Undefined error is returned.

 
WORKS: 
  session.evaluate( @If(Status='AwaitingApproval';Approver;"")  , doc)[0]  
 
DOESN'T WORK:
  session.evaluate( @If(Status='Awaiting Approval';Approver;"")  , doc)[0]  
 
I think it might just be a syntax error but any help would be appreciated. 
Thanks 
Mel 
May 31, 2012, 5:54 AM
16 Posts
Re: session.evaluate Fails if the formula has a space
 Hmmm.... Just a quick try: Use " instead of ' around the text constant that your are testing in the if statement.
 
/John 
May 31, 2012, 11:27 AM
586 Posts
Re: session.evaluate Fails if the formula has a space
 Mel,
 
You really shouldn't be using session.evaluate for this.  You should use pure SSJS.  I don't know where you're using this but it would be better to do something like this: 
 
var approver // Set this value here
var docStatus = document1.getItemValueString("status") 
 
if (docStatus == "Awaiting Approval") {
   // It is awaiting approval 
   return approver;
   } 
   else { 
   // It is NOT equal to awaiting approval 
   return ""; 
 
 
You should only use session.evaluate when you really need to.  For instance.  If I do a new "@Unique()" in XPages to get a unique number, it's this weird Java based time stamp.  If I do session.evaluate("@Unique") then I get an "old school" number like DLEY-85MUY.
 
Server Side JavaScript is easy to learn as LotusScript was.  But SSJS is so much more powerful the LotusScript.
 
good luck! 
 
Jun 4, 2012, 4:01 AM
8 Posts
Re: session.evaluate Fails if the formula has a space

Thanks so much for the responses guys. I'm a little embarrassed to say I found the problem.

In my attempt to make the problem easier to understand I cut down the code so much that my problem doesn't show here.

So here goes.

My full code is designed to export a list of fields from documents in a collection.

Some of the fields required a formula to calculate which field to export. That’s why I used evaluate.

 

I have a config doc that allows me to create a configurable list of fields to export.  I pass the list as an array, and silly me didn’t make the connection that a space would be seen as a separator in my array.

So when the evaluate ran on this formula:

@If(Status='Awaiting Approval';Approver;"")

It was failing because it was actually running on this formula

@If(Status='Awaiting

So now I have fixed the handling of my array and it works, just like it should.

So I’m very sorry for wasting your time and I thank you very much.

PS David I’m a huge fan, you have taught me so much with your notes@9 videos.

Jun 4, 2012, 12:11 PM
586 Posts
Re: session.evaluate Fails if the formula has a space
 Mel,
 
Thanks for watching!  Really appreciate that!! 
 
Is there a reason that you're doing an @if statement like this in XPages rather then using SSJS? the more you do in normal SSJS the better live will become for you.  I was scared at first...  but it's really not that much different then lotusscript. 

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