Hwo to use currency type in catalog variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 03:15 AM
Hello Everyone,
I wanted to create a variable with type as currency is there any type to display ??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 03:22 AM
Hi Irfan,
Check the below links.
Scripting Currency and Price Fields - ServiceNow Wiki
can you create a currency field in the service catalog?
Hope this helps.
Regards
Ujjawal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 09:59 AM
Hello Shaik,
Please go through below link which is similar to your query
How to define variables of type Price in the Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 10:02 AM
//Replace cost with your variable name:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var cost = g_form.getValue('cost');//Replace cost with your variable name:
cost = cost.trim();
// first character should be dollar sign
var firstChar = cost.substring(0,1);
if (firstChar != '$') {
alert ("Please enter cost in $0.00 format");
g_form.setValue("cost", oldValue);//Replace cost with your variable name:
return;
}
// characters after the $ sign should be numerics
var costType = isNaN(cost.substring(1));
if (costType == true) {
alert ("Please enter cost in $0.00 format");
g_form.setValue("cost", oldValue);//Replace cost with your variable name:
return;
}
// entered value should have a decimal point
var num = cost.substring(1);
if (num.indexOf('.') == -1) {
alert ("Please enter cost in $0.00 format");
g_form.setValue("cost", oldValue);//Replace cost with your variable name:
return;
}
// there must be 2 digits only after the decimal
var decNum = num.substring(num.indexOf('.')+1, num.length);
if (decNum.length != 2) {
alert ("Please enter cost in $0.00 format");
g_form.setValue("cost", oldValue);//Replace cost with your variable name:
return;
}
}
Note: enter value must have '.' decimal value
Cheers
Abdul Azeez
---------------
Note: Hit like, Helpful or Correct depending on the impact of the response