Create multiple task using business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2022 01:22 AM
Hi Everyone,
I am creating task using business rule on case table. But my requirement is to create multiple task based on drop down. I have field on case table call "tasks" , it is a drop down field. Based on value I choose from that field the tasks must be created. Please help to create array for this task.
BR:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var cs = new GlideRecord("sn_customerservice_task");
cs.initialize();
cs.parent = current.getUniqueValue();
cs.description = current.short_description;
cs.priority = current.priority;
cs.assignment_group = current.assignment_group;
cs.assigned_to = current.assigned_to;
cs.insert();
})(current, previous);
Thanks in advance
cc: @Ankur Bawiskar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2022 01:24 AM
Is it a Dropdown or a list field? Can you select more than one value in that field?
What logic you want to implement to create multiple tasks? Like, what should differ he child tasks from each other
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2022 01:31 AM - edited ‎10-14-2022 01:39 AM
It is a drop down and it's choices are 1,2,3,4 and 5 . I can select any of these values and based on number , the number of tasks should be created.
This is new Business rule I have created , it is not working:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var test = current.u_tasks;
var temp = new Array();
temp = test();
for (var i = 0; i < temp.length; i++); {
var cs = new GlideRecord("sn_customerservice_task");
cs.initialize();
cs.parent = current.getUniqueValue();
cs.description = current.short_description;
cs.priority = current.priority;
cs.assignment_group = current.assignment_group;
cs.assigned_to = current.assigned_to;
cs.insert();
}
})(current, previous);
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2022 01:41 AM
Use the below code
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var test = current.u_tasks;
for (var i = 0; i < test; i++); {
var cs = new GlideRecord("sn_customerservice_task");
cs.initialize();
cs.parent = current.getUniqueValue();
cs.description = current.short_description;
cs.priority = current.priority;
cs.assignment_group = current.assignment_group;
cs.assigned_to = current.assigned_to;
cs.insert();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2022 01:47 AM
Hi @suvro
The above code is still producing 1 task only . Whatever value I chose from drop down it created only 1 task.
Regards