- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 08:04 AM
Hello Community,
I have a client script for the Requested Item table that sets currency to CAD if the user's country is Canada. The functionality works as required, however I need some assistance with adding the following logic to my script:
If user's country = CA and the 'price' field = 0.00
Client Script:
function onLoad() {
// Get Current User
var user = new GlideRecord("sys_user");
if (user.get(g_user.userID)) {
// If Canadian, set currency to CAD
if (user.country == 'CA' && g_form.getValue('price') == 'USD;0.00') {
g_form.setValue('price.currency', 'CAD');
}
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 11:44 AM
Here you go
function onLoad() {
// Get Current User
var user = new GlideRecord("sys_user");
user.addQuery("sys_id",g_user.userID);
user.query();
if(user.next()){
// If Canadian, set currency to CAD
if (user.country == 'CA' && g_form.getValue('price') == 'USD;0.00') {
g_form.setValue('price.currency', 'CAD');
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 11:17 AM
Hi Keesh,
The code seems fine. just test it once and check if it is working fine.
g_form.getValue('price') == 'USD;0.00' looks fine
But not sure whether you can set CAN for canada
Check this should help:
https://community.servicenow.com/community?id=community_blog&sys_id=583eaa6ddbd0dbc01dcaf3231f9619fa
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 11:44 AM
Here you go
function onLoad() {
// Get Current User
var user = new GlideRecord("sys_user");
user.addQuery("sys_id",g_user.userID);
user.query();
if(user.next()){
// If Canadian, set currency to CAD
if (user.country == 'CA' && g_form.getValue('price') == 'USD;0.00') {
g_form.setValue('price.currency', 'CAD');
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 01:07 PM
Thank you abhinay 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 01:16 PM
you bet!