How to change number prefix including existing records.

Vivek Prakash
Tera Contributor

My current requirement is to change number prefix on a custom table say "DOC" to "NO". Will the changes be applied to existing records as well?

1 ACCEPTED SOLUTION

Musab Rasheed
Tera Sage
Tera Sage

Hello,

Go to Number mantainence table and find entry for your table and make changes, It will affect new records, it won't reflect in existing records. You have to run background script or fix script to change prefix of existing records. Please see below link

https://servicenowguru.com/scripting/changing-number-prefix-existing-records/

Also Number maintaince table link:

https://yourinstance/nav_to.do?uri=%2Fsys_number_list.do%3Fsysparm_userpref_module%3D10e86ef3c61122750035cf9c7f4d00dc%26sysparm_clear_stack%3Dtrue

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

View solution in original post

2 REPLIES 2

Musab Rasheed
Tera Sage
Tera Sage

Hello,

Go to Number mantainence table and find entry for your table and make changes, It will affect new records, it won't reflect in existing records. You have to run background script or fix script to change prefix of existing records. Please see below link

https://servicenowguru.com/scripting/changing-number-prefix-existing-records/

Also Number maintaince table link:

https://yourinstance/nav_to.do?uri=%2Fsys_number_list.do%3Fsysparm_userpref_module%3D10e86ef3c61122750035cf9c7f4d00dc%26sysparm_clear_stack%3Dtrue

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Mohith Devatte
Tera Sage
Tera Sage

Hello @Vivek Prakash ,

for changing the prefix you can follow below steps

Go to number maintainance

find_real_file.png

Search for you table and update it 

find_real_file.png

You would have to write a fix script to update the number for the existing records .It will only be applicable to new records like below 

Replace your number field back end name in below script

var gr = new GlideRecord('your custom table name');
gr.query();
while(gr.next())
{
var number = gr.number.split('DOC'); // replace your number field back end name
var splt = 'NO'+number[1];
gr.number=splt;// replace your number field back end name
gr.update();
}

please mark my answer correct if it helps you