Create multiple tasks for one catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 12:05 AM
Hi,
I have created a catalog item which has a list variable. This list variable is used to select users from the user table.
What I am trying to achieve: when the RITM gets approved, it should create a task for each user in the list variable.
Attempts did: I tried to create the task from the workflow using "Run Script". It did create the required number of tasks for one RITM, but I cannot see any variables of the RITM in the Variable tab of TASK.
The script I used to create task is:
//users = list variable
//
var a=current.variables.users;
var a_split=a.toString().split(',');
for(var i=0;i<a_split.length;i++)
{
var gt=new GlideRecord('sc_task');
gt.initialize();
gt.short_description='task created: '+i;
gt.request_item=current.sys_id;
gt.assignment_group.setDisplayValue('Client Support');
gt.parent = current.sys_id;
gt.insert();
}
Please find the RITM and TASK screenshot attached.
I would prefer the variables to appear on the variable Tab, but also the "Requested for:" should have only the user from the list variable. Is it possible?
Thanks,
Dibeena
- Labels:
-
Service Catalog
-
Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 12:21 AM
requested for field on the RITM and Task is coming from request, it will be always dot walk field.
check global checkbox on the variables it will show on the task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 05:40 AM
Thanks, Girish. I made the variables global and now I can see the variables in the TASK.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 12:22 AM
Hi Dibeena,
Can you please share Run Script code you have used?
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 12:32 AM
//users = list variable
//
var a=current.variables.users;
var a_split=a.toString().split(',');
for(var i=0;i<a_split.length;i++)
{
var gt=new GlideRecord('sc_task');
gt.initialize();
gt.short_description='task created: '+i;
gt.request_item=current.sys_id;
gt.assignment_group.setDisplayValue('Client Support');
gt.parent = current.sys_id;
gt.insert();
}