Approval based on variable contains

Jake Adams
Tera Contributor

Hi,

 

I have a reference variable that has the reference of 'Business Unit' table.

I want the approval to go based on the Business unit contains, but it's not working for me.

 

In the User approval activity I am using advanced.

 

var answer = [];

if (current.variables.business_unit.indexOf("abc") > -1) {
answer.push(gs.getProperty('approval.one'));
} else {
answer.push(gs.getProperty('approval.two'));
}

 

Kindly assist

12 REPLIES 12

@Jake Adams 

oh yes, I am sorry. can you keep '-1' in quotes and try once.

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful

var answer = [];

if (current.variables.business_unit.getDisplayValue().indexOf("abc") > -1) {
answer.push(gs.getProperty('approval.one'));

gs.log("Business: " + current.variables.business_unit.getDisplayValue().indexOf("abc") > -1);

//gs.log("Approver One: " + answer);
} else {
answer.push(gs.getProperty('approval.two'));

//gs.log("Approver Two: " + answer);

gs.log("Businesssss: " + current.variables.business_unit.getDisplayValue().indexOf("abc") > -1);

}

 

I have added it and in the log it is coming as false

@Jake Adams 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader