- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 11:19 AM
Hello!
Currently I am trying to query a user locations based off of the "requested_for" variable. The location of the user resides on the field "u_exp". The "requested_for" variable points to the sys_user table and is grabbing the logged in user as a default value. My final goal: If a user is from a certain location ex: US, then make another variable read-only and mark the checkbox true.
However I have not had any luck, even though I thought I was setting up the query correctly. Any help is much appreciated as I am new to the scripting.
Thanks!
var usr = g_user.userID();
var uq = new GlideRecord('sys_user');
uq.addQuery('sys_id',usr);
uq.query();
if(uq.next()){
alert(usr);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 05:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 11:33 AM
Hi Stephen,
Please check the below link. I have pasted a script here which will help you
Hide Variable based on Requester's Location
Regards,
Ark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 02:05 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 02:14 PM
you can try with getReference() function to check the location field and the take appropriate action.
function onChange(control, oldValue, newValue, isLoading) {
var caller = g_form.getReference('requested_for', doAlert);
}
function doAlert(caller) {
if (caller.u_exp.name== 'US') //dot walk to location field name
g_form.setDisplay('citizen', false); // Please check if citizen field name is correct
else
g_form.setDisplay('citizen', true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 02:25 PM
explorenow that was also unsuccessful. I have verified that "citizen" is the correct variable name on the catalog form. "u_exp" contains the information for the location as a single-line text string value