- 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
10-21-2020 11:50 AM
It is a bery bad practice use GlideRecord in Client side scripts