How to display the entered values in a comma-separated format

mi2022
Tera Contributor

Hi,

 

I want to convert the values entered by the user on the record producer with comma separation so that the values are set.

Is there a way to make it happen?

Regards,

1 ACCEPTED SOLUTION

Hi @mi2022 

Use onChange catalog client script on that single line text variable as below

 

var input=newValue;

var output = input.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");

g_form.clearValue('SingleLineTextVariableName');

g_form.setValue('SingleLineTextVariableName',output);


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

View solution in original post

4 REPLIES 4

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @mi2022 ,

What types of values end users are entering ?

What will be the criteria for values separation e.g after 2 character/1 character?

Please provide more details in order to understand use case.


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Hi,

Thank you.

I want a comma to be set for every three threads, such as 1,234 or 1,234,567.

Regards,

Hi @mi2022 

Use onChange catalog client script on that single line text variable as below

 

var input=newValue;

var output = input.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");

g_form.clearValue('SingleLineTextVariableName');

g_form.setValue('SingleLineTextVariableName',output);


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Sonu Parab
Mega Sage
Mega Sage

Hi @mi2022 ,
Have a look at this post.  need a script to push multiple values with comma seperated 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
Thank You