Development of Fix Script to change incidents
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2023 01:00 PM
Hey guys!
I need a Fix Script to change the name of the Channel field (contact_type) for 365 incidents:
Basically I need to replace "ChatBot" with "Chatbot".
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2023 01:25 PM
Hello @lucasjt ,
you can you this code:
var incidentGR = new GlideRecord('incident')
incidentGR.addQuery('contact_type', 'ChatBot') // check if this query returns the 365 records or build the right query to get only the records you want to update
incidentGR.query()
while(incidentGR.next()){
incidentGR.contact_type = "Chatbot";
incidentGR.update()
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2023 01:28 PM
You can try the below:
var updateINC = new GlideRecord('incident');
updateINC.addEncodedQuery('contact_type=INSERT BAD CONTACT TYPE');
//updateINC.setLimit(); //Use to limit number of records to update at a time, if a large number of reocrds are to be updated then there might be a performance impact.
updateINC.query();
while (updateINC.next()) {
updateINC.contact_type = 'GOOD CONTACT TYPE';
//Prevent BRs/Flows/Workflows from Triggering
updateINC.setWorkflow(false);
//Prevent updated by and updated fields from changing
updateINC.autoSysFields(false);
updateINC.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2023 04:50 PM
Hi @LucasJ using batch update instead of a while loop would be more efficient. Update mutiple will update all records just like the while loop. You should still set workflow and sysfields to false.
see --
Hope that helped
--
Bala