- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 08:26 AM
Hi Experts
I want to change the INC numbers to INCQ its already my incidents in my servicenow data base.
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 08:38 AM
1. Please open the Number Maintenance (sys_number) table.
2. Search for incident table.
3.
4. Please mark my answer helpful and correct.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 01:51 PM - edited 03-11-2024 02:02 AM
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
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 08:29 AM
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
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 08:33 AM - edited 03-05-2024 08:41 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 08:37 AM - edited 03-05-2024 08:39 AM
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 08:38 AM
1. Please open the Number Maintenance (sys_number) table.
2. Search for incident table.
3.
4. Please mark my answer helpful and correct.
Regards,
Amit