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

Can you check if the table on BR you selected is sc_req_item, and when to run condition is after insert? can you provide the exact code/ BR screenshot please?

suvro
Mega Sage
Mega Sage

What are the values of the dropdown ?? what should be the behavior when value changes ?

ersureshbe
Giga Sage
Giga Sage

Hi,You achieve through many ways. I'm just explaining below approach. Create a workflow based on your requirement i.e, create many tasks and create a new task based on existing task closure. You should call the workflow in business rule

 

   wrkflw.startFlow(wflw.getWorkflowFromName('Call WF toBR'),current,current.operation());

 

ersureshbe_0-1665736518813.png

 

Create a flow designer based on the do above actions. 

 

Regards,

Suresh.

Regards,
Suresh.

SanjivMeher
Kilo Patron
Kilo Patron

Can you try this?

var task_count = ParseInt(current.u_tasks);

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

var cs = new GlideRecord("sn_customerservice_task");
cs.newRecord();
cs.parent = current.getUniqueValue();
cs.short_description = current.short_description;
cs.priority = current.priority;
cs.assignment_group = current.assignment_group;
cs.assigned_to = current.assigned_to;
cs.insert();
}

 


Please mark this response as correct or helpful if it assisted you with your question.