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

priyasunku
Kilo Sage

Hi @Jake Adams 

 

can you keep logs and check if it is entering the if loop and also is it storing the value in answer.

 

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Jake Adams 

so what's not working? what debugging did you perform so far?

are you sure both the properties have proper sysId of user/group?

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

Hi,

Even though the business unit contains abc it is still going to the second approval user.

Yes both the properties have the correct sysid of the user

@Jake Adams 

what's your analysis after adding gs.info() statements?

since the variable is reference do this

var answer = [];

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

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