How to pass list collector values in workflow?

prasanna7869
Mega Expert

Hi Team,

IN Knowledge Management, we have one List collector type field "" this field contains Malaysia, Japan, China etc..For example, if I'm selecting Malaysia, Japan, China countries, based on these countries we need to send approval request their respective managers.

For Malaysia the approval request mail will send to two persons (managers)

For China the approval request mail will send to one manager

For Japan the approval request mail will send to three managers.

Previously, "" is a drop-down field and it contains above country name. So, in workflow we simply using switch case, approval user and send approval request mail to respective managers.

But, here my query is how to get "" values in workflow and how to send individual approval request to respective mangers.

Please suggest a solution/helpful script/workflow, to how can i get Article for and how to send individual approval request to respective mangers.

Previous Workflow: Previously "Article for" is a drop down values. But now it is a list collector type.

1. Fieldfind_real_file.png

2. Previous Workflow

find_real_file.png

Please suggest how can I update this workflow with present situation.

Thanks & Regards,

Prasanna Kumar

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Prasanna,



You can click on advanced checkbox on approval activity and then trigger it based on your logic.


Script :


var answer =[];


var arrayUtil = new ArrayUtil();


var list = current.list_collector.getDisplayValue().toSring();


var arrayList = list.split(",");


if (arrayUtil.contains(arrayList, "Malaysia")) { //for ex if it is Malaysia


  answer.push('PASS SYS_ID OF THE APPROVAL USER');  


}



You can adjust the above code as per your logic.


View solution in original post

14 REPLIES 14

Pradeep,



I am trying this now, but getting an error:


find_real_file.png


find_real_file.png



I know that List Collector field has a value in it and it is Framework.



Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

I fixed it Pradeep...this line needed variables in it:



find_real_file.png



Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

You are right. I'm glad you got it resolved


Thanks for participating in the community!


Chuck Tomasi
Tera Patron

Hi Prasanna,



Thank you for the picture. It was very helpful. Without it, we could have gotten off to a bad start. Just to be clear, you are dealing with a List field, not a List Collector. A list collector (also known as a slushbucket) looks like this:



find_real_file.png



This may be helpful in the future when dealing with list fields from scripts:



Managing Glide Lists


sk59
Tera Expert

Hi All,

Can you all please help me out with the above similar issue. The issue here is I need to attach workflows based on the values selected in the list collector.

 

Appreciate your response