- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2018 12:07 AM
Hi SNOW users,
I have a Service catalog form with a single line text variable. I need to make it to accept only numerical values.
Is there any similar validation properties available for any of the variables in service catalog
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2018 12:50 AM
HI Andrew,
Have a look.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var number = g_form.getIntValue('u_quantity');
//if "Not a Number", clear the number value
if (isNaN(number)){
//number = "";
g_form.setValue('u_quantity','');
g_form.showFieldMsg('u_quantity','Please enter a valid integer number - stripping out non-numeric characters','info');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2018 12:22 AM
HI Andrew
There is no numeric type available for variables. Yo can write a client script to enforce numeric value to the required field.Check below script
var var_name= g_form.getValue('VARIABLE_NAME');
var a = var_name.match(/^[0-9]+$/);
if(a == null){
g_form.clearValue('VARIABLE_NAME');
g_form.showFieldMsg('VARIABLE_NAME','this field should be numeric value only','error');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2018 12:50 AM
HI Andrew,
Have a look.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var number = g_form.getIntValue('u_quantity');
//if "Not a Number", clear the number value
if (isNaN(number)){
//number = "";
g_form.setValue('u_quantity','');
g_form.showFieldMsg('u_quantity','Please enter a valid integer number - stripping out non-numeric characters','info');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2018 02:20 AM
Hi Raju,
But this validation will hapen only after the order is submitted right? we can't do any validations prior that?
-Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2018 02:31 AM
Andrew,
This client script is on Onchange condition. when ever variable value is changed- script will trigger to work.