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.

Approval based on check box selection in Catalog Item

Aavi
Mega Guru

Hi,

 

I have multiple check box type variable. Based on there selection, the approval should gone to particular user.

 

For ex: I have 3 check box variables viz. a, b, c.

  • If a user selects a, then approval should be gone to 1 user
  • If a user selects b, then approval should be gone to 2 user
  • If a user selects c, then approval should be gone to 3 user
  • If a user selects all three of them i.e. a, b, c, then approval should be gone to 1, 2, 3 respective users.

I have used below script in "Approval user" activity in workflow

var answer = [];
if (current.variables.a = true) {
answer.push("4e6f97291b3ce01019c25fc4464bcbd7"); //(1 user sys id)
}
if (current.variables.b = true) {
answer.push("5100a7291b7860107e64a86fe54bcbfc"); //(2 user sys id)
}
if (current.variables.c = true) {
answer.push("bbaf53a91b3ce01019c25fc4464bcb07"); //(3 user sys id)
}

 

Now problem is, every time am selecting any 1 or 2 checkbox out of 3. It is sending approval to all 3 users.

 

Please Help!!!

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @Aavi ,

 

Just use this, it will work

current.variables.a == 'true'

 

if this solves your problem mark this as correct and helpful.

 

View solution in original post

12 REPLIES 12

praneeth7
Tera Guru

Hi @Aavi 

Can you try with "else if" in your script like this,

var answer = [];
if (current.variables.a = true) {
answer.push("4e6f97291b3ce01019c25fc4464bcbd7"); //(1 user sys id)
}
else if (current.variables.b = true) {
answer.push("5100a7291b7860107e64a86fe54bcbfc"); //(2 user sys id)
}
else if (current.variables.c = true) {
answer.push("bbaf53a91b3ce01019c25fc4464bcb07"); //(3 user sys id)
}

if you find this useful kindly mark my answer as Accepted Solution and Helpful,

Thank you

No, its not working

hello @Aavi 

try using "==" instead of "=".

thank you.

Community Alums
Not applicable

Hello @Aavi ,

 

You need to use == operator instead of = operator for comparing.

Replace = with == and than check if it's working or not.

 

If this solves your issues than mark this as correct and helpful.

 

Regards

Anand