Variable data validation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2016 11:14 AM
Hey There Community!
Trying to do something that seems pretty straight forward but having a hard time finding the best mechanism to achieve this.
We have a requested item in our service catalog in which we'd like to do some data validation on.
When users fill out the variables in the form, one of them should require that it be a 15 digit number and not allow the user to proceed until that one field meets the requirements.
Hoping to get some feedback on what people have done to achieve a similar goal.
Thanks,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2016 11:50 AM
Mark,
You can write an onChange client script on the variable you want to validate and below script to check for any non digit characters and if the length is 15.
Note:You can also write an onSubmit to alert the error message and blank out the variable value if the conditions are not satisfied and stop submitting the form
//'number_field' is my variable name
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(/\D/g.test(newValue)==false){
if(newValue.length==15){
}
else{
g_form.setValue('number_field','');
alert("Enter 15 digits");
}
}
else{
g_form.setValue('number_field','');
alert("Only digits allowed");
}
}
Thanks,
Abhinay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2016 12:00 PM
Thanks so much for your reply, One question in regards to this.
One of the things i am trying to figure out is, when I create the client script, what table is it running against? Since it is a variable in the requested item, i assume it would be sc_req_item?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2016 12:12 PM
Mark,
As far as I know, in catalog client scripts, table field does not matter at all. It applies to a specific catalog item.
Please mark this question as answered if my response has provided a resolution or if you need further assistance, please let me know
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2016 12:33 PM
Thanks!
You rock!!!