Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Business rule to align start and end dates of change with change tasks

lmao
Tera Contributor

hello dear community,

 

im trying to create a BR which will trigger when the start or end date of a change changes.

It then should fill the start and/or end date of the related change task(s).

 

It seemed at first like a quick fix but for some reason the BR wont trigger. I have tried to use a script and the script debugger but although i trigger it, the BR isnt running. I have tried to change the order and the "when" but nothing seems to help. 

Its the same in my PDI, i think there is something i miss.

 

For help and suggestions i will be very grateful,

 

 

 

CHGdate.png

CHTASKdate.png

BR.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@lmao 

you can use flow or you can use after update BR on change_request table

Condition: Start Date Changes OR End Date Changes

Script:

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

    // Add your code here
    var gr = new GlideRecord("change_task");
    gr.addQuery("change_request", current.getUniqueValue());
    gr.query();
    while (gr.next()) {
        gr.planned_start_date = current.start_date;
        gr.planned_end_date = current.end_date;
        gr.update();
    }

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Community Alums
Not applicable

Hi @lmao  You can try following script to resolve your issue.

polnilesh99_1-1738066316800.png

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@lmao 

you can use flow or you can use after update BR on change_request table

Condition: Start Date Changes OR End Date Changes

Script:

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

    // Add your code here
    var gr = new GlideRecord("change_task");
    gr.addQuery("change_request", current.getUniqueValue());
    gr.query();
    while (gr.next()) {
        gr.planned_start_date = current.start_date;
        gr.planned_end_date = current.end_date;
        gr.update();
    }

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

thank you a lot for the help, its now working!