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



Aug 29, 2012, 12:45 PM
90 Posts

Error handling as you go.... how to?

  • Category: Debugging
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: error handling
  • Replies: 2
In classic Notes, I'm used to checking my work every step of the way, like this:
Temp := something;
Temp := @If(@IsError(Temp);"";Temp);
 
 How can I do that in xpages? I've got this working but it seems really long winded.
 
var TSDefaults = @DbLookup(dbStaff,'(Timesheet Defaults)','Setup', 2)
if (TSDefaults && typeof TSDefaults == "string")
    TSDefaults = TSDefaults
else
    TSDefaults = "not found";
applicationScope.put("TSDefaults",TSDefaults)
 
 
And I tried this, but it doesn't work always just returns "no found" (though I know it is found)
 
 var TSDefaults = @DbLookup(dbStaff,'(Timesheet Defaults)','Setup', 2)
TSDefaults = @If(@IsError(TSDefaults),"Not Found",TSDefaults = "","Blank", TSDefaults)
 
Randal
 
 
 
 
 
Aug 29, 2012, 1:14 PM
14 Posts
Re: Error handling as you go.... how to?
Try to see if the var is undefined when you return nothing:
 
var TSDefaults = @DbLookup(dbStaff,'(Timesheet Defaults)','Setup', 2)
 
if (TSDefaults != undefined) {
 //found
} else { 
 // not found
 
I've not tried it, but I've been using an  undefined test in a few other SSJS functions. 
 
Cheers, 
Brian 
Aug 29, 2012, 1:54 PM
90 Posts
Re: Error handling as you go.... how to?
thanks brian, i was hoping for something a bit more compact, and i think I found it

var TSDefaults = @DbLookup(dbStaff,'(Timesheet Defaults)','Setup', 2) 
TSDefaults = (typeof TSDefaults == "string") ? "No result" : TSDefaults

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