How to create auto increment variable in service catalog
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2022 08:56 PM
Hi,
Use case:
when on change field i need to have the other variables prefixed with text and auto increment number.
Example:
Based on other field change my variable need to prefix with auto number like"TEMPxxxxxx". Please advise how we can achieve this in Service catalog.
Thanks
Srini
Labels:
- Labels:
-
Service Catalog
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2022 10:14 PM
Hi Author,
The only way to do this is using the OnChange() client script, Could you try the below approach?
1.) First set some default value for your number variable
2.) Write onChange() client script on another variable
function onChange(oldValue, newValue, isLoading, isTemplate) {
if(newValue) { //If another variable is not empty
var number = g_form.getValue('number_variable'); //First fetch the default value from the variable
var incrementNumber = Number(number) + 1; //Number() function is used to convert into number
g_form.setValue('number_variable', incrementNumber) //Set the incremented number
}