Need help for custom variable validation in Catalog client script Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 08:25 PM
I have below requirement.
there is variable name Estimated Cost
Type : it should be upto 2 decimal places or numeric and need to show in SAR currency.
written below code for decimal and numeric checking but how to add currency in Variable??
var decimalRegex = /^\d*(\.\d{1,2})?$/;
g_form.hideFieldMsg('estimated_cost', true);
if (!decimalRegex.test(g_form.getValue('estimated_cost'))) {
g_form.showFieldMsg('estimated_cost', 'Estimated cost must be a numeric or decimal value.', 'error');
}
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 12:29 AM
can you please send some test cases and screenshot of error message.
what I have tested is 123 SAR , 234.33 SAR
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 12:58 AM
The below is the error not even accepting numeric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 01:06 AM
as you want it to be currency specific regex should contain "SAR" in the variable.
Can you try with these test cases it should work
e.g., 400 SAR , 567.78 SAR
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates