Is there a way to generate multiple tasks to various assignment groups via a script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2018 05:25 AM
Just wondering if there is a way to generate multiple tasks - 1 Task for each assignment group needed via a script.
Instead of creating multiple tasks, I want to create 1 task and inside of the task via the Advanced is there a script that can be used to generate additional tasks to other assignment groups.
Not sure if this is even possible.
Thanks,
Karen

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2018 05:54 AM
You can create activity "Run script", and in it to create the necessary number of tasks using GlideRecord
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2022 07:11 AM
can you share the code please
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2018 06:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2018 06:06 AM
Like Viktor says you can use a run script
This is one based on a list collector variable that selects business services.
var varReferenceTable = "cmdb_ci_service";
var temp = current.variables.app_collection;
var tasks = temp.toString().split(",");
var variableRec = new GlideRecord(varReferenceTable);
//tasks.pop();
for(var i=0; i < tasks.length; i++){
var gr = new GlideRecord('sc_task');
var user = new GlideRecord('sys_user');
user.get(tasks[i]);
gr.initialize();
gr.request_item = current.sys_id;
variableRec.initialize();
variableRec.get(tasks[i]);
var sgroup=variableRec;
gr.order =i;
gr.assignment_group = sgroup.support_group;
gr.short_description = gs.getMessage("Create Access to ") +' '+variableRec.getDisplayValue() + " - "+ current.u_item_requested_for.getDisplayValue();
gr.state = 1;
gr.insert();
}
So it creates a task with an order and a short description that includes the requested for and the name of the business service. Assigns it to the support group defined in the business service etc
We use it in access request items