Script required to create multiple change task

sravya03
Tera Contributor

I have a requirement to create change task after submitting catalog item on SP.

so before creating change task, created change request by using create task activity.

Immediately after that used another create task and created change task.

By creating task in this way, change tasks are not coming under the change request .

So created after BR on change request table based on short description.

if(current.short_description == 'ABCD')
    {
    var gr = new GlideRecord("change_task");
    gr.initialize();
     gr.assignment_group='fc8fd289db1e72406340dbbb5e961915';
    gr.state ='1';
    gr.description= 'XXXX';
    gr.change_request=current.sys_id;
    gr.insert();
    }
    if(current.short_description == 'ABCD')
    {
        var br = new GlideRecord("change_task");
        br.initialize();
     br.assignment_group='da10013a87c4c914864c0faf8bbb35a4';
    br.state ='1';
    br.description= task.description = 'nhsl';
    br.change_request=current.sys_id;
    br.insert();
    }
 
My main issue is to create multiple change task with diff assignment groups and description but under same change request.
 
1 ACCEPTED SOLUTION

Hi @sravya03 Please find the below Business rule condition to create 3 Change task under Change after change creation.

 

EswarChappa_0-1692431468652.pngEswarChappa_1-1692431492079.png

EswarChappa_2-1692431559151.png

 

(function executeRule(current, previous /*null when async*/) {
    
        createChangeTask(current, current.assignment_group, 'Description for Task 1');
        createChangeTask(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();
}

 

 

Cheers, hope that helps

Eswar Chappa

*** Please mark as "Correct" or "Helpful" as appropriate ***

View solution in original post

8 REPLIES 8

Hi @sravya03 the relation between RITM and Change is "Parent" as shown below, Then you need to update the Parent field value of change request with the current RITM sys id in Workfllow task,It will show

EswarChappa_0-1692713978150.png

 

 

thanks @Eswar Chappa 

 

Hi @Eswar Chappa 

for above code can we add wait for completion and if yes ,can you tell how?

sravya03
Tera Contributor

task.u_parent_requested_item =current.sys_id;

Can i write above line in cretae task script