The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Fix inconsistent data

Community Alums
Not applicable

When my predecessors first set up our Service-now instance, they inadvertently created a lot of inconsistent data that I have now been asked to fix.

The specific current problem is that they created categories with Proper Case labels but lower case values, for example Software|software. This is a problem because Service-now is case sensitive. When a user replies to a notification email, the ticket is updated with the Proper Case Label, overwriting the correct, lowercase value. The Category is then flagged as invalid (becomes blue), can't be found by reports, and Dependent relationship to Subcategory breaks.

I can fix the values for categories going forward, but I need to know if it is possible to fix the existing data. For example, I need to know the S-n method of running:


UPDATE Incident
SET Category = "Software"
WHERE Category = "software"

Can this be done, and if so how? If not, is there any way to make my data consistent again, or do we need to just throw it all out and start over?

Thank you
2 REPLIES 2

Community Alums
Not applicable

anything?


stranger_tepa
Kilo Contributor

Greetings,

Updating data should not be a big of a deal. What you can do is create a script and run it through a schedule job once.

The script should look something like:
var incidents = new GlideRecord( "incident" );
incidents.query();

while( incidents.next()){
switch( incidents.category){
case "software":
incidents.category = "Software";
break;
// add your remmainning categories here
}
incidents.update();
}

That should take care of the problem.

If the capitalization is the only problem, you can omit the swith statement and just capitalize the first letter by code, and then update the record.