Fix Script

yoli1
Tera Contributor

Hi Team can someone explain to me what is a fix script so i created a business role that change the statut based on a state

and i need to create a fix script to update  initially all the records that have that state to the correct statut

Thanks!

1 ACCEPTED SOLUTION

SwarnadeepNandy
Mega Sage

Hello @yoli1,

 

A fix script is a server-side JavaScript code that runs after an application is installed or upgraded. You can use fix scripts to make changes that are necessary for the data integrity or product stability of an application, such as adding, updating, or deleting data, rules, scripts, or property settings.

If you created a business rule that changes the status based on a state, and you want to update all the existing records that have that state to the correct statuses, you can create a fix script that queries the table and updates the status field accordingly. For example, you can use the following code to update the status of all incidents that have the state “New” to “Open”:

 

var gr = new GlideRecord('incident');
gr.addQuery('state', 'New');
gr.query();
while (gr.next()) {
  gr.status = 'Open';
  gr.update();
}

 

You can modify the code to suit your needs and test it before running it on production. For more details on how to create, test, and run fix scripts, see this article or this article. I hope this helps. 😊

 

Best Regards,

Swarnadeep Nandy

View solution in original post

7 REPLIES 7

@yoli1 

https://www.servicenow.com/community/developer-forum/unloadable-and-run-once-fields-in-fix-scripts/m...

This explains.

 

Option to create Customer Update records [sys_update_xml] when the fix script runs.

Fix script tests enforce the Unloadable option.

@SwarnadeepNandy When i refresh the table in dev the old value is still there do you know where the problem might be?