i need to trigger a approvals based on variable values in workflow

chinna
Mega Guru

Hi team,

i have requirement like in the workflow i have multiple fields like reference and select box  variables .

for example if the field is ABC has values (yes and no). and another field DEF has values (yes and no) and 1 more field XYZ has values (none,include and exclude) .

 

if the ABC value is yes and DEF value No and XYZ value is None based on this condition i want to trigger a approval in workflow for requestor manager.

otherwise ABC value is No and DEF value YES and XYZ value is include based on this condition i want to trigger a approval for Particular group.

 

can anyone help me with the script.

 

Regards,

Chinna

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

you can use here if activity in your workflow. you will add it before the approval activity 

now in if activity you will check the above condition and then return your transition to further step.

 

eg:

 

 

answer = ifScript();

function ifScript() {
var cNum = current.variales.<variale name abc>;

var cNum1 = current.variales.<variale name def>;

var cNum2 = current.variales.<variale name xyz>;


if (cNum == 'yes' && cNum1 =='No' && cNum2 == 'None') {

return 'yes';
}
else{

return 'no';
}
}

after if activity you will add user approval and group approval activity.

you will take if activity transition yes to user approval and no to group approval activity. 

 

https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/workflow-activities/r...

View solution in original post

6 REPLIES 6

Harsh Vardhan
Giga Patron

you can use here if activity in your workflow. you will add it before the approval activity 

now in if activity you will check the above condition and then return your transition to further step.

 

eg:

 

 

answer = ifScript();

function ifScript() {
var cNum = current.variales.<variale name abc>;

var cNum1 = current.variales.<variale name def>;

var cNum2 = current.variales.<variale name xyz>;


if (cNum == 'yes' && cNum1 =='No' && cNum2 == 'None') {

return 'yes';
}
else{

return 'no';
}
}

after if activity you will add user approval and group approval activity.

you will take if activity transition yes to user approval and no to group approval activity. 

 

https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/workflow-activities/r...

Hi Harshavardhan,

 

thanks for the response,  it works for only 1 approver .

 

for example if i have 3 different approvals based on the variables values, like

1.Cnum=yes, cnum1= no cNUm2 =none,(triggers approval manager)

2.Cnum=No, cnum1= Yes cNUm2 =include,(triggers approval fulfulment group)

3..Cnum=Yes, cnum1= Yes cNUm2 =exclude,(triggers aprroval to deployement group)

on that time how can i approch?

so instead using if activity you can use here switch activity and check the condition there and based on it take the transition to further approval activity. 

 

https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/workflow-activities/r...

can you please help me with the script