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:46 AM
i think it should be working properly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 05:43 AM
Thanks for that.
One issue is still there. Each TASK shows all the users.I selected two users and it is preferable to see only one user as "Requested For:" in one TASK. Is it possible
Is it possible to show only one user in each TASK as "Requested For:"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 05:49 AM
i think for that you will have to create seperate request since requestedfor is always inherited from request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2017 04:18 PM
Thanks for the help. I am now able to show the user's name in the short description field.
I created a field (user) in the item and was wondering whether I can populate that field with the corresponding username along with the creation of tasks?
Thanks,
Dibeena
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2017 11:06 PM
I have modified my script as below:
var a=current.variables.users.getDisplayValue();
var a_split=a.split(',');
for(var i=0;i<a_split.length;i++)
{
var gt=new GlideRecord('sc_task');
gt.initialize();
gt.short_description='task created: '+a_split[i];
gt.description='task created for SAP access' +a_split[i];
gt.request_item=current.sys_id;
gt.assignment_group.setDisplayValue('Client Support');
gt.parent = current.sys_id;
gt.start_date = current.u_request_date;
gt.due_date = current.due_date;
//fill user field with the correspondign user's name
current.variables.usr = a_split[i];
//Can perform additional functionalities if u want
gt.insert();
}
------------------------------------------------------------------------------------------------------------------
I used "current.variables.usr = a_split[i];" to fill my user variable of the task with relevant user's name, but it is filling up with the last selected user's name in all TASKS.
Will anyone be able to tell me on what I could be missign/doing wrong?
Thanks,
Dibeena