Create change task when change request is created(Not more than one change task for change request), and in case exiting change request is updated respected change task should get updated.

kartik1
Tera Contributor

I have only tried this,

(function executeRule(current, previous /*null when async*/ ) {

var gr = new GlideRecord("change_task");

gr.initialize();
gr.change_request = current.sys_id;
gr.insert();
gs.addInfoMessage(gr.number+"",'Change task has been created ');


})(current, previous);

1 ACCEPTED SOLUTION

Filipe Cruz
Kilo Sage
Kilo Sage

Hello kartik,

That code works for the creation of the change_task.
For the update you can do a similar code:

(function executeRule(current, previous /*null when async*/ ) {

    var gr = new GlideRecord("change_task");
    gr.addQuery("change_request", current.sys_id);
    gr.query();
    while(gr.next()){
       gr.field = current.field;
       gr.update();
    }
  

})(current, previous);

 

Please update the line gr.field = current.field to use the right fields that you want to update.

Hope this helps!

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards,

Filipe Cruz

View solution in original post

2 REPLIES 2

Filipe Cruz
Kilo Sage
Kilo Sage

Hello kartik,

That code works for the creation of the change_task.
For the update you can do a similar code:

(function executeRule(current, previous /*null when async*/ ) {

    var gr = new GlideRecord("change_task");
    gr.addQuery("change_request", current.sys_id);
    gr.query();
    while(gr.next()){
       gr.field = current.field;
       gr.update();
    }
  

})(current, previous);

 

Please update the line gr.field = current.field to use the right fields that you want to update.

Hope this helps!

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards,

Filipe Cruz

Thank You