Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

If condition in workflow script is not working as expected

Renu9
Tera Contributor

Hi All,

 

I was comparing 2 reference fields in workflow script as below.

If new_owner is not the same as the one who is requested the item. Then, new owner should receive an approval request. If not , then it has to auto approve.

 

This script is written in IF condition block:

var newowner = current.variables.new_owner;
var reqfor = current.variables.requested_for;
answer = ifScript();

function ifScript() {
if (newowner != reqfor) {
return 'yes';
}
return 'no';
}

 

Even though newowner is not same as reqfor, it is going to Yes part. But it has to go to No. 

Please help me in resolving this.

1 ACCEPTED SOLUTION

you should not use apostrophe(' ')

use this : answer.push(current.variables.new_owner)

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain

View solution in original post

5 REPLIES 5

you should not use apostrophe(' ')

use this : answer.push(current.variables.new_owner)

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain