Catalog variable – how to create number/Amount field

LokeshwarReddy
Tera Contributor

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).

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@LokeshwarReddy 

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! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader