Set Active Flag to false on cancelled changes

doonwong
Kilo Contributor

Hi,

I'm fairly new to SNOW development and I'm looking to set the active flag on a change request to false when the change state is set to cancelled as these are currently staying active.

Please advise on the best way to go about this.

Regards,

Paul

1 ACCEPTED SOLUTION

Alikutty A
Tera Sage

Hello,

You need to write a one time scheduled job to fix it.

 

var gr = new GlideRecord('change_request');
gr.addEncodedQuery('state=4^active=true');  //Replace with your cancelled state query.
gr.query();
while(gr.next()){
gr.active = false;
gr.update();
}

You could also write a before update business rule with condition as State changes to cancelled and Set value for Active to False. This will ensure that all new records are synchronized.

Thanks

View solution in original post

1 REPLY 1

Alikutty A
Tera Sage

Hello,

You need to write a one time scheduled job to fix it.

 

var gr = new GlideRecord('change_request');
gr.addEncodedQuery('state=4^active=true');  //Replace with your cancelled state query.
gr.query();
while(gr.next()){
gr.active = false;
gr.update();
}

You could also write a before update business rule with condition as State changes to cancelled and Set value for Active to False. This will ensure that all new records are synchronized.

Thanks