Auto numbering for Catalog item Variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 03:24 AM
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?
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 03:42 AM
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 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 04:34 AM
Hi Aman,
Could you please share a sample scripting on how i can achieve this?
Regards,
Syed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 04:42 AM
Hi,
can you explain the business requirement for generating it?
how and where it will be used?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 04:47 AM
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.