Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Activity condition always returns no

Rachael12
Tera Contributor

I have written a simple code and am getting the correct logs but always No conditions gets triggered.

answer = ifScript();
 
function ifScript() {
var val = gs.getProperty('test_pr');
gs.log("Value: " + val);
    if (val == "test1") {
gs.log("Print no");
        return 'no';
    } else{
gs.log("workflow.scratchpad.test: " + workflow.scratchpad.test);
if(workflow.scratchpad.test == 'test2'){
gs.log('Print test2');
return 'test2';
}
gs.log('Print test complete');
        return 'yes';
}
}

Logs printed :
Value: test1
workflow.scratchpad.test: test2
Print test2
It should return test2 and condition holding activity.result == 'test2' should be called but instead it goes to No condition.

What could be the reason.

1 REPLY 1

GlideFather
Tera Patron

hi @Rachael12 

This script is in a workflow?

 

i’m on a mobile without proper chances to verify myself, but to get:

activity.result == 'test2'

 

try something like:

activity.result == answer

 

eventually try ===

 

keep me updated about your progress

_____
This reply is 100 % GlideFather and 0 % AI