- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2022 11:54 AM
Hello, can someone help me with the following?
I need to carry out a process for the Software license requirements, where each software has a group and for each selected software it is necessary to create 1 automatic task with the update to the "user entitlements" table, if the software has rights available, the insert and if there are no available licenses, a task must be created where a person in charge is assigned and when there are available licenses, they must generate the record.
Currently the software is assigned to 3 different groups, each software in the workflow is separated to the corresponding group,
but my problem is that I can't find a way to separate each software so that each software has its own task created, the limit of software used is 5 per request
Could someone guide me to achieve this separation in the workflow with a script? or if it is possible in a flow designer?
also if it is possible to achieve this? or is there any other way?
thanks, I hope someone can guide me a little on this issue
best regards
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2022 07:27 PM
In workflow you can access the sys_ids of each of the selected software items in a script, then loop through them to create a task for each of them. You will need to create the catalog tasks via the script, but you can still track the status of the Workflow's execution by using a Wait for condition step to check that all tasks under the main request have been completed before moving on in the workflow.
The general idea with the script would be something like below, modify it to suit your instance.
This code would go into a "Run Script" workflow activity.
var softwareIds = current.variables.software_name.getValue(); //change software_name to be the actual variable name
var softwareArray = softwareIds.split(","); //changes from a csv of sys_ids into a real array
softwareArray.forEach(function (id){
var softwareGR = new GlideRecord("software_table");
softwareGR.get(id); // optional step to let you access extra info about the software like it's name or other properties
var taskGR = new GlideRecord("sc_task");
taskGR.newRecord();
taskGR.setValue("request_item", current.getUniqueValue()); //make sure the task is linked to the parent request
taskGR.setValue("short_description", softwareGR.getValue("name"));
//add extra details to the task as needed
taskGR.insert();
})
After this script has run, it should have created a task per item in the list variable.
I would recommend adding a Wait for condition step after the script field to check that there are no active tasks left under the RITM before continuing with the workflow, but that depends on your requirements.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2022 07:27 PM
In workflow you can access the sys_ids of each of the selected software items in a script, then loop through them to create a task for each of them. You will need to create the catalog tasks via the script, but you can still track the status of the Workflow's execution by using a Wait for condition step to check that all tasks under the main request have been completed before moving on in the workflow.
The general idea with the script would be something like below, modify it to suit your instance.
This code would go into a "Run Script" workflow activity.
var softwareIds = current.variables.software_name.getValue(); //change software_name to be the actual variable name
var softwareArray = softwareIds.split(","); //changes from a csv of sys_ids into a real array
softwareArray.forEach(function (id){
var softwareGR = new GlideRecord("software_table");
softwareGR.get(id); // optional step to let you access extra info about the software like it's name or other properties
var taskGR = new GlideRecord("sc_task");
taskGR.newRecord();
taskGR.setValue("request_item", current.getUniqueValue()); //make sure the task is linked to the parent request
taskGR.setValue("short_description", softwareGR.getValue("name"));
//add extra details to the task as needed
taskGR.insert();
})
After this script has run, it should have created a task per item in the list variable.
I would recommend adding a Wait for condition step after the script field to check that there are no active tasks left under the RITM before continuing with the workflow, but that depends on your requirements.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2022 01:13 PM
Hello Luke,
thank you very much for your support, I will try to do that, I really appreciate your help!
best regards