How do I return the error text from an @Dblookup
? I have similar lookups that I suspect that are returning an error so I want to have a panel that displays when a lookup error occurs.
I have:
var dbpath = @DbLookup("","Setup","Setup","EIDBServerFilename");
var tmp = @DbLookup(dbpath,"FullName",@Name("[ABBREVIATE]" ,getComponent("inputTextEmpName").getValue()),"HRLogonID");
@If(@IsError(tmp),"Error= " + @Text(tmp),"");
But I am just seeing "Error= " with no error text.
If I remove the @Text
I get "Error = undefined".
How do I get the error message if it is an error?
I looked up both @IsError
and @Dblookup
in help but as usual the help is horrendous and does not even mention @Dblookup
could return an error nor what to do about it.
Errors from a @DbLookup in SSJS are internaly catched and will not returned.
This is because it is realized via session.evaluate, and if you make a bad @DbLookup in a session.evaluate, the full evalulation fails and you won't receive the error message of the @DbLookup.
In case of a bad @DbLookup, null is returned, and this is what you are testing with @IsError: tmp is null, this is why you get an undefined in your string.
If you make a @Text with a undefined value, an empty string is returned.
Hope this helps
Sven
EDIT:
If you run code in an evaluate statement you are able to get the error message. F.e. this
session.evaluate('lookup:=@DbLookup("";"";"X";"1";1);@if(@isError(lookup);@Text(lookup);lookup)')
would return the error message.