change my incident numbers from starts INC to INCQ.

dhineshkumar
Tera Guru

Hi Experts 

I want to change the INC numbers to INCQ its already my incidents in my servicenow data base.

 

Thank you.

2 ACCEPTED SOLUTIONS

Amit Pandey
Kilo Sage

Hi @dhineshkumar 

 

1. Please open the Number Maintenance (sys_number) table.

2. Search for incident table.

3. 

AmitPandey_0-1709656648099.png

4. Please mark my answer helpful and correct.

 

Regards,

Amit

 

View solution in original post

Robbie
Kilo Patron
Kilo Patron

Hi @dhineshkumar,

 

Did you see my earlier response?

(Assuming you've done the due diligence and qualified the 'why' here of the requirement. Whilst relationships should not be broken, if any code any been implementing something checking for INC you will need to review these area's))

 

To answer your question directly:

Go to 'Number Maintenance' via the navigation menu. From there you can update the number prefix of tables. 

Search for the table prefix of INC to update the existing record. Change it from INC to INCQ and hit save.

Job done. (Screen shot below)

 

Note, this will reflect for incidents moving forward, you'll have to create a fix script for Incident records already created. Sample fix script below - however please exercise with caution and make your you test using a single record first so as to make sure no relationships or code referencing INC breaks or is affected by this change.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

 

Robbie_0-1709674309027.png

Fix Script or Background Script sample code:

 

 

//Use a single record for testing purposes only. Example here using INC0008111
var testSingleRecord = 'INC0008111';
var incGR = new GlideRecord('incident');
//Ensures we don't pick up any records that have been updated with INCQ
incGR.addEncodedQuery('numberNOT LIKEINCQ'); 
//Comment the below line when happy with single record testing
incGR.addQuery('number', testSingleRecord)
incGR.query();
while(incGR.next()){
   //Change the number prefix from 'INC' to 'INCQ'
   incGR.number = incGR.number.replace('INC', 'INCQ');
   incGR.setWorkflow(false); //Do not run business rules
   incGR.autoSysFields(false); //Do not update system fields
   //Uncomment when ready to update
   incGR.update();
   //Comment when happy with testing
   gs.print('No after: ' + incGR.number);
}

 

 

 

 

View solution in original post

5 REPLIES 5

Robbie
Kilo Patron
Kilo Patron

Hi @dhineshkumar,

 

Did you see my earlier response?

(Assuming you've done the due diligence and qualified the 'why' here of the requirement. Whilst relationships should not be broken, if any code any been implementing something checking for INC you will need to review these area's))

 

To answer your question directly:

Go to 'Number Maintenance' via the navigation menu. From there you can update the number prefix of tables. 

Search for the table prefix of INC to update the existing record. Change it from INC to INCQ and hit save.

Job done. (Screen shot below)

 

Note, this will reflect for incidents moving forward, you'll have to create a fix script for Incident records already created. Sample fix script below - however please exercise with caution and make your you test using a single record first so as to make sure no relationships or code referencing INC breaks or is affected by this change.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

 

Robbie_0-1709674309027.png

Fix Script or Background Script sample code:

 

 

//Use a single record for testing purposes only. Example here using INC0008111
var testSingleRecord = 'INC0008111';
var incGR = new GlideRecord('incident');
//Ensures we don't pick up any records that have been updated with INCQ
incGR.addEncodedQuery('numberNOT LIKEINCQ'); 
//Comment the below line when happy with single record testing
incGR.addQuery('number', testSingleRecord)
incGR.query();
while(incGR.next()){
   //Change the number prefix from 'INC' to 'INCQ'
   incGR.number = incGR.number.replace('INC', 'INCQ');
   incGR.setWorkflow(false); //Do not run business rules
   incGR.autoSysFields(false); //Do not update system fields
   //Uncomment when ready to update
   incGR.update();
   //Comment when happy with testing
   gs.print('No after: ' + incGR.number);
}