How to create multiple catalog task using workflows.

stevethomas
Giga Contributor

We have an OnBoarding process where the hiring manager can select what software the new hire needs.  The hiring manager selects from a List Collector.   We have a workflow that creates a Catalog Task, which shows the list collector, and in right hand column has the software selected.  I want to create two more Catalog tasks using a condition. 

  1. If the software selected has, “Software2” in the list then create “Catalog task 2”.
  2. If the software selected has, “Software3” in the list then create “Catalog task 3”.
  3. The current Catalog Task which list all software select still needs to be create weather “Software2” or “Software3” is in the selected list or not.

I was looking at using the Switch Activity but not sure, if this will work and not sure, how to configure the Switch Activity if this what I need to use.

1 ACCEPTED SOLUTION

Slava Savitsky
Giga Sage
Use Branch activity to create three branches running in parallel, each for a certain task. In two of them, use If activity to ensure tasks 2 & 3 are only generated if needed.

View solution in original post

3 REPLIES 3

Mohit Kaushik
Mega Sage
Mega Sage

Hi There,

you can use an if condition after the creation of your first catalog task and in that if condition activity you can filter your list collector variable using a script and based on the value of the if condition you can create catalog task 2 or catalog task 3.

Script to extract values from list collector can be used like this:

var myList = current.variables.my_variable.getValue(); // or using this workflow.variables.variableName

var myArray = myList.split(',');

for (var i = 0; i < myArray.length; i++) {

    var gr = new GlideRecord('my_table');

        if (gr.get(myArray[i])) {

                  // Do what you want to the retrieved record

        }

}

 

You can refer the below thread as well:

https://community.servicenow.com/community?id=community_question&sys_id=f4adcf2ddb9cdbc01dcaf3231f96...

 

Please mark this answer as correct and helpful if it resolved the query or of it lead you in right direction then just mark helpful alone.

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Slava Savitsky
Giga Sage
Use Branch activity to create three branches running in parallel, each for a certain task. In two of them, use If activity to ensure tasks 2 & 3 are only generated if needed.

Thanks for the help Slava.