- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 09:21 AM
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!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 09:34 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 09:25 AM
Fix Script is a Server side script that can be used on demand.
You can create a fix script to loop through the records and update the status. Add Glide Record query on the same.
Create a fix script (servicenow.com)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 09:34 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 10:06 AM
If my answer solves your problem, can i please request you to mark my answer correct. It will be useful for other community members.
Kind Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 10:15 AM
Hi @SwarnadeepNandy what does Unloadable stands for when creating a fix script?