Create multiple task using business rule

Abhijit Das7
Tera Expert

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 

13 REPLIES 13

use 

var test = parseInt(current.u_tasks);

Hi @suvro 

Still same, only 1 task is being created.

Thanks

Hi,

 

Small correction next to the for loop, semicolon (;) need to be removed as below

 

for (var i = 0; i < test; i++)  {

 

Regards,

Bala T

 

Hi Abhijit,

 

 

Can you try the below code, this might work for you as it worked for me. You can check it using background script for quick test.

 

var test=current.u_tasks.getDisplayValue();

var cs = new GlideRecord("sn_customerservice_task");

for (i=1; i<=tasks; i++){
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();
}

 

Thanks!

Hi @Himabindu4 

 

I used your code, but now not even a single task is being created.