Can you tell me what I am doing wrong? I am looking to set property pAPIcall_Filter to true if getROL_ID starts with an integer.
if (getROL_ID.search(/^d/)){
log.debug("Starts with an integer ");
next.setProperty('pAPIcall_Filter', true);
} else {
log.debug("Does not start with an integer ");
next.setProperty('pAPIcall_Filter', false);
}
Its not working as designed, as seen in the screenshot.
I am sending these two values, KANEJ2 and 573871, the condition thinks they both start with an integer.
2
Answers
Since
search
returns-1
(which is not zero, nor falsy), this is atrue
expression.You should use:
Or, better yet:
If you want to correct your logic, compare the result to
-1
:A simple approach is to check a static string.
Here is an example.