Retrieve User Location with Catalog Client Script

spinol611
Giga Contributor

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);

}

1 ACCEPTED SOLUTION

find_real_file.png


Appreciate your help explorenow on pointing me in the right direction.



Thanks!


View solution in original post

11 REPLIES 11

Hi Stephen,



The script seem to be ok, but not sure about the values in your form if you are using them correctly.



I would suggest to add log statement in the script include to check u_exp display value.



Also, you need to write an alert on the client script to check the answer or the response you are getting.



I highly recommend not to use dot walking in client script as dot walking will work upto only one level in client script and its not a best practice


Harsh Vardhan
Giga Patron

Hi Stephen,



can you try to write the glide query in script include and call it catalog client script using glide ajax.


writing glide query in client script in not a good practice.


if you have any further question please let me know



what is GlideAjax ?How to write Ajax function? | Ahmed Drar


https://snprotips.com/blog/2016/2/6/gliderecord-client-side-vs-server-side