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

SanjivMeher
Kilo Patron
Kilo Patron

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.

Hi @SanjivMeher @suvro 

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

 

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);

Hi @suvro 

 

The above code is still producing 1 task only . Whatever value I chose from drop down it created only 1 task.

Regards