Auto numbering for Catalog item Variable

Syed Ahmed2
Tera Contributor

Hi,

I am trying to create a variable called 'Asset name' for a catalog item. I have created a single text type variable with Default value javascript:getNextObjNumberPadded(); I am now getting a value 'Variable0010000' Now i want to replace the prefix 'Variable' which i am getting with my own prefix. How can i achieve this?

6 REPLIES 6

Aman Kumar S
Kilo Patron

Hey,

This is being controlled by a Global business rule "getNextObjNumberPadded".

You might want to manipulate this to meet your requirement but I will strongly recommend against, since how it will behave for different tables will be difficult to test as well has will result in performace issue since it is a global BR

What you can do here as a workaround:

1. You can set the value onSubmit or onLoad, and AJAX call based on your requirement

2. Write up a script include to check the already existing Assets names and get the number with highest value increment that by 1 and set in your field on catalog item

3. In the script include for the first entry set it as "1000001" or something like that if there are no records, if found one add one to the last and return as "ASN1000002".

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

 

 

 

Best Regards
Aman Kumar

Hi Aman,

Could you please share a sample scripting on how i can achieve this?

 

Regards,

Syed

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

can you explain the business requirement for generating it?

how and where it will be used?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

It will be used in hardware table to populate the field Asset Name. It needs to be 9 character alphanumeric code. Starting with USV or NLV as prefix based on user location.