Changing Prefix of a Table Auto Number.

sriharshitha
Tera Contributor

Hi all, I have a requirement to change the prefix of Auto number field in the table which I got from integration. I have tried working with changing the prefix in studio. But it is not giving me the correct output. I want to know what are the other ways to do this. The more ways possible the better result I can get. Thanks for responding to this question. Every answer is valuable in one way or other. 

 

 

Can I know how to do this with the help of transform scripts

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Hi

there are two steps:

  • Change the prefix over the module "Number maintenance"
    find_real_file.png
  • Write a fix script which replaces the old prefix with the new prefix in all existing records.

Maik

View solution in original post

5 REPLIES 5

Maik Skoddow
Tera Patron
Tera Patron

Hi

there are two steps:

  • Change the prefix over the module "Number maintenance"
    find_real_file.png
  • Write a fix script which replaces the old prefix with the new prefix in all existing records.

Maik

Sagar Pagar
Tera Patron

Hi,

Navigate to System Defination ---> Number maintenance and check for respective table and change the prefix.

 

Thanks,
Sagar Pagar

The world works with ServiceNow

But I need to change existing records as well

Hi,

For existing records, you have to update it by Backgroud scripts or fix scripts.

 

Try this sample scripts -

//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();
}

 

Thanks,

Sagar Pagar

 

The world works with ServiceNow