How can we put First Character as Dollar Sign on Catalog Item variable field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2025 03:23 AM
How can we put First Character as Dollar Sign on Catalog Item variable field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2025 03:51 AM - edited ‎02-02-2025 06:34 AM
Hello ,
you can use below regular expression on the variable
^\$
and do setting for your regualr expression on variable like below
In this way you will achieve your requirement without scripting, rest is your choice as there are mulitple ways of doing a thing.
I hope this information helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2025 03:54 AM - edited ‎01-31-2025 03:55 AM
Hi
we try to achieve this requirement by adding on-change client script with following code in it.
you just do edit and put you variable name in SetValue method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2025 04:34 AM
set the default value as $ in the variable configuration and the users can type in the value there
OR
you can use onChange catalog client script and let user type and then add the prefix, ensure it doesn't get into loop
Something like this
function onChange(control, oldValue, newValue, isLoading) {
if (!isLoading || newValue == '') {
return;
}
if (!newValue.startsWith('$')) {
g_form.setValue('variableName', '$' + newValue);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2025 05:30 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader