- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 09:08 PM
Hi All,
How to add currency variable for catalog item in service catalog , do you have any idea how to do that ?
field label | type |
|
Preferred phone price | Currency Input | Currency input field. Euro/Pound Symbol |
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 09:26 PM - edited 01-18-2024 09:30 PM
Hello @suha2 ,
As Currency variable type is not present in the catalog item you need to create Single Line text type variable and you need add validations to it by creating onChange Client script.
The below link will help to create onChange client script so, go through below link:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 01:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 01:51 AM
I have created same client script in my PDI , it is working properly:
Please check did you miss anything. Please refer below screenshot:
code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var cost = g_form.getValue('cost');
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);
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);
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);
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);
return;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 02:06 AM
Now it's working .Thank you !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 01:57 AM
Hi @suha2
Currency type is not OOTB available. You can use single line text.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************