The CreatorCon Call for Content is officially open! Get started here.

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

Edit:

I think switch activity will not work here, because you have not one specific variable. 

 

using if activity it can be done. i am sorry for this confusion.

kindly have a look on below blow to add more condition . it will help you. 

 

https://community.servicenow.com/community?id=community_blog&sys_id=d1fde22ddbd0dbc01dcaf3231f961912

Thanks harshavardhan, its very helpful.