- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2014 12:29 PM
Hello all,
I have tried a number of things, but can't seem to populate this reference field. Here is the scenario:
This Catalog Item has a reference variable to pull current user from the sys_user table. I have another reference field on the catalog item to the cmn_location. This is also a reference field in the sys_user table. The client wants their location to auto populate. I tried dot walking, and querying, but can't seem to get the reference field to populate. when I try to display this is an alert I get [Object] [Object].
I've went through my stages of different code, but for visual purposes here is the onLoad client script:
var gr = new GlideRecord('sys_user'); | |
gr.addQuery('user_name', g_form.getValue('customer_info_requestor')); | |
gr.query(); |
while(gr.next()){
g_form.setValue('visitor_access_which_post', gr.location); |
}
Any Ideas?
Solved! Go to Solution.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2014 01:17 PM
Found the solution, just took a lot of testing and . Thanks for y'alls help!
In case someone else runs into this problem here was the solution:
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '') {
g_form.setValue('visitor_access_which_post', '');
return;
}
if (!g_form.getControl('visitor_access_which_post'))
return;
var caller = g_form.getReference('customer_info_requestor', setLocation);
}
function setLocation(caller) {
if (caller)
g_form.setValue('visitor_access_which_post', caller.location);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2014 12:38 PM
Hi Nathan,
Could you try using "variables" prior to variable name? Check if that does any difference in the outcome
Thanks,
Mandar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2014 12:44 PM
Hey Mandar,
This is a catalog client script, not a client script, so if you mean using variables.variable_Name this does not work either. It's driving me crazy.
Thanks,
Nathan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2014 01:17 PM
Found the solution, just took a lot of testing and . Thanks for y'alls help!
In case someone else runs into this problem here was the solution:
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '') {
g_form.setValue('visitor_access_which_post', '');
return;
}
if (!g_form.getControl('visitor_access_which_post'))
return;
var caller = g_form.getReference('customer_info_requestor', setLocation);
}
function setLocation(caller) {
if (caller)
g_form.setValue('visitor_access_which_post', caller.location);
}