Need to add wait for completion feature in the business rule

sravya03
Tera Contributor
function executeRule(current, previous /*null when async*/) {
    
        createChangeTask(current, current.assignment_group, 'Description for Task 1');
        create(ChangeTask(current, current.assignment_group, 'Description for Task 2');
        createChangeTask(current, current.assignment_group, 'Description for Task 3');
   
})(current, previous);

function createChangeTask(change, assignmentGroup, description) {
    var gr = new GlideRecord("change_task");
    gr.initialize();
    gr.assignment_group = assignmentGroup;
    gr.state = '1';
    gr.description = description;
    gr.change_request = current.sys_id;
    gr.insert();
}

 

 

I have written above business rule to generate change tasks but need to add a condition like 2nd task should be created after the first task ..

2 REPLIES 2

Sandeep Rajput
Tera Patron
Tera Patron

@sravya03 Instead of handling the sequential task creation via a business rule, I recommend creating these tasks via a workflow or flow. This flow/workflow can have a wait for condition activity/action and can create a new task once the previous task is created.

sravya03
Tera Contributor

@Sandeep Rajput  thanks for the reply.

I have used workflow activities only finally.

I have one more doubt which i posted as question.

Can you pls click on below link

https://www.servicenow.com/community/developer-forum/not-able-to-copy-change-number-to-change-task-i...