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

Eswar Chappa
Mega Sage
Mega Sage

Hi @sravya03 in the above BR you can be able to create one task under change request ,Can you please specificy your requirement bit more elaborative manner for better understanding

 

Thanks & Regards

Eswar Chappa

sravya03
Tera Contributor

@Eswar Chappa  I want 3 change tasks to be created(simultaneously) under one change request with diff assignment groups and description.

I need script to achieve that,I have written the above script but only one change task is getting created.

 

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 ***

Hi @Eswar Chappa  

Thanks for the help.

Need one more help on other requirement.

I have to create 2 change requests through Workflow which is on sc_req_item table.

I have used create task and created but that change request number is not visible on request item form(in related list 'change request' tab).

Is there anything can be done