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

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @dhineshkumar 

 

You need to force on Number field but it will can break the system logic. Dont change for old record. For new records change here first

 

AGLearnNGrow_0-1709656135792.png

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Robbie
Kilo Patron
Kilo Patron

Hi @dhineshkumar,

 

I'll assume you've done the due-diligence and qualified the 'why' here of the requirement.

 

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.

Note, this will reflect for incidents moving forward, you'll have to create a fix script for Incident records already created.

 

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

 

Screenshot 2024-03-05 at 16.35.31.png

 

Sumanth16
Kilo Patron

Hi @dhineshkumar ,

 

Go to System Definition> Number Maintenance, locate the incident table and update prefix from INC --> INCQ.

 

But existing records won't update. You need to write one time fix script and need to rename to INCQ.

 

Screenshot 2024-03-05 at 10.33.12.png 

For existing record write script like below:

//Query for your table
var record = new GlideRecord('table_name');
record.query();
while(record.next()){
   //Change the number prefix from 'OLD' to 'NEW'
   record.number = rec.number.replace('OLD', 'NEW');
   record.setWorkflow(false); //Do not run business rules
   record.autoSysFields(false); //Do not update system fields
   record.update();
}

 

Note: If you have any scripts with old record numbers (or) script contain incident number queries , those scripts will break.

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

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