How to write a workflow approval script?

AnkitT
Tera Contributor

Hello Community,

 

I need to write an approval script for workflow based on some different condition in a single activity. How should I configure it.

2 ACCEPTED SOLUTIONS

Abhishek_Thakur
Mega Sage

Hello @AnkitT ,

 

You can refer this example script to configure the multiple approval based on different condition within the single activity.

 

var answer = [];
if(current.variables.user_type.getDisplayValue()=='OT Admin'){
    answer.push('c201085597032110db1d7c9fe153af76');
}else if(current.variables.select_site.getDisplayValue()=='BNE'){
    answer.push('c201085597032110db1d7c9fe153af76');
}else if(current.variables.select_site.getDisplayValue()=='MOR'){
    answer.push('8741445597032110db1d7c9fe153af53');
}else if(current.variables.select_site.getDisplayValue()=='GRO'){
    answer.push('7ac1005597032110db1d7c9fe153af9e');
}else if(current.variables.select_site.getDisplayValue()=='DSN'){
    answer.push('0ee28c1597032110db1d7c9fe153af71');
}else if(current.variables.select_site.getDisplayValue()=='CAP'){
    answer.push('6d030c5597032110db1d7c9fe153af46');
}else if(current.variables.select_site.getDisplayValue()=='AQU'){
    answer.push('bb73849597032110db1d7c9fe153afbd');
 
Please accept my answer and give thumbs up, if it helps you.

 

View solution in original post

Abhishek_Thakur
Mega Sage

If still you need any guidance, you can connect with me.

View solution in original post

3 REPLIES 3

Abhishek_Thakur
Mega Sage

Hello @AnkitT ,

 

You can refer this example script to configure the multiple approval based on different condition within the single activity.

 

var answer = [];
if(current.variables.user_type.getDisplayValue()=='OT Admin'){
    answer.push('c201085597032110db1d7c9fe153af76');
}else if(current.variables.select_site.getDisplayValue()=='BNE'){
    answer.push('c201085597032110db1d7c9fe153af76');
}else if(current.variables.select_site.getDisplayValue()=='MOR'){
    answer.push('8741445597032110db1d7c9fe153af53');
}else if(current.variables.select_site.getDisplayValue()=='GRO'){
    answer.push('7ac1005597032110db1d7c9fe153af9e');
}else if(current.variables.select_site.getDisplayValue()=='DSN'){
    answer.push('0ee28c1597032110db1d7c9fe153af71');
}else if(current.variables.select_site.getDisplayValue()=='CAP'){
    answer.push('6d030c5597032110db1d7c9fe153af46');
}else if(current.variables.select_site.getDisplayValue()=='AQU'){
    answer.push('bb73849597032110db1d7c9fe153afbd');
 
Please accept my answer and give thumbs up, if it helps you.

 

Abhishek_Thakur
Mega Sage

If still you need any guidance, you can connect with me.

Jitendra Diwak1
Kilo Sage

Hi @AnkitT,

 

Please try to keep the sys-id in system properties so you will not need to make changes in workflow. you call create the sys_properies_list.do and create new one and put the sys_id of group in value field. So you will not need to go though the CHANGE to make the different group to be set on some condition. here is below example:

var answer = [];
if(current.variables.user_type.getDisplayValue()=='Network'){
    answer.push(gs.getproperties('geive the property name here');
}
 
Please accept my solution if it works for you and thumps up.
 
Thanks
Jitendra
Please accept my solution if it works for and thumps up.