Catalog variable – how to create number/Amount field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi,
I have a requirement to create an “Enter Amount” field in a Service Catalog item.
I tried to find Number or Integer field types in catalog variables, but I couldn’t find any option like that.
My requirement is to have a field that accepts only numeric values, and if possible, it should work like a budget field with $ (currency).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
you can only have string type variable and then add variable validation regex to handle the validation
something like this using onChange catalog client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || !newValue)
return;
var re = /^\d+(\.\d{1,2})?$/;
if (!re.test(newValue)) {
g_form.showFieldMsg('enter_amount', 'Enter a valid amount, for example 100 or 100.00', 'error');
g_form.clearValue('enter_amount');
}
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader