- 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 02:28 PM
Edit: Did get something working when I removed ".name". Will work it and post any other questions/answers.
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 02:30 PM
yes, as recommended dot walking to field name, if u_exp is a string field the you don't need to do dotwalking, removing name should work for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 02:46 PM
explorenow ok I have it working 99% of the way but I am having problems with setting it to Read-Only. Here is my script:
The read-only works for the user that is populated into the "requested_for" variable. However, if I switch to another user that does not meet the criteria, the item remains read only, but doesn't check the box. Is there a way to fix this?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 02:53 PM
is citizen is true/false field? can you please remove the quotes when setting the value and try like
if(caller.u_exp == 'US'){
g_form.setValue('citizen', true); // remove quotes from true keyword
{
else{
g_form.setValue('citizen', false); // remove quotes from false keyword
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 05:53 AM