- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2020 05:15 AM
Hi,
I have a customer that is requesting to have multiple Tasks (26) created at the same time after the request is approved and when Tasks are all completed then it will create a single Task as Final Review.
I created all Task boxes and using the Branch after the approval and Join after Tasks but it is crazy having all these boxes. It seems also to affect the server performance.
Is there a way to use a Script to create 26 different Tasks at once, each Task has a different short/long descriptions and assignment groups. Also it requires to have all Tasks completed before creating the Final Review Task.
Your help will be much appreciated, I'm a bit lost at this point.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2020 07:40 AM
Hi,
I considered it as catalog form with those many checkboxes
If that is for normal table and field then you can modify the logic
But the syntax would remain the same
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2020 05:21 AM
Hi,
sample script below you can use workflow run script
if(current.variables.checkbox1.toString() == true){
createTask('group sysId 1', 'My Task1');
}
if(current.variables.checkbox2.toString() == true){
createTask('group sysId 2', 'My Task2');
}
function createTask(groupSysId,shortDesc){
var gr = new GlideRecord('sc_task');
gr.initialize();
gr.request_item = current.sys_id;
gr.request = current.request;
gr.assignment_group = groupSysId;
gr.short_description = shortDesc;
gr.insert();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2020 05:47 AM
Thanks Ankur,
Q. Where should I add the short description for each Task and assignment group names?
It is a different description and group names for each of them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2020 07:08 AM
Hi Andre,
If you want different short description and different assignment group then you need to pass those 2 values to that function for each checkbox condition
I have passed those as function parameters to createTask()
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2020 07:36 AM
Ankur,
One other thing that I see in your script, it mentions checkbox, I don't have any checkbox in my request.
The Tasks are not referring to any request form variable. It is a simple request form to decommission servers and apps (enter only server or app name in a single text line).
So when the request is reviewed and approved, it initiates and involves 26 different teams with their respective task to perform, so this is why it needs different short description and assignment groups.
Hope it will clarify my point.
Thanks