- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 12:49 PM
I've done something wrong, and I don't seem to actually be calling my script include. And if I am, I'm not seeing it in the debugger, and definitely not getting the expected results:
Reference Qualifier:
Script Include:
When a user searches for an assignment group, if they have a specific value set in their Company attribute, they should only see a subset of available Assignment Groups. My test user always sees all the groups, causing me to think I'm either failing to call the function -OR- I'm always falling into the 'else' part of the script (which they shouldn't be).
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 12:55 PM
Hi there,
A couple of things:
1. You cannot chain together GlideRecord methods like you currently have coded, each method needs to include the GlideRecord object like userCheck.method(). So something like this instead:
var userCheck = new GlideRecord('sys_user');
userCheck.addQuery('user_name', userID);
userCheck.addQuery('company', 'company_sys_id');
userCheck.query();
2. In your reference qualifier where you have g_user.userName, replace that with gs.getUserName() which is the proper method for retrieving logged-in user's user ID via server script. The g_user class is meant to be used from client-side scripts.
If this answer is helpful please mark correct and helpful!
Regards,
Christopher Perry
Regards,
Chris Perry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2022 09:53 AM
My errors were at a higher level - and required details that I didn't include!
We're working on the Case form (sn_customerservice_case.do), and that table is in the Customer Service application scope.
I modified the script include to be accessible from all scopes, and the predicated the call to it with 'global.' so that we could call the include from the Customer Service scope. Done and done.
Thank you again for pointing out the issues with my code!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 12:57 PM
I don't believe you can use g_user in this context. Try current.user_name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 01:44 PM
Doesn't current. pull the variable value from the form? i.e., if there were a variable on the form named user_name, it would pull whatever value was in the field?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 01:51 PM
Yes, your understanding is correct. Using 'current.user_name' would not work in this context unless this reference qualifier is on the sys_user table...and even then it would be pulling in the User ID of the current user record, not the user ID of the logged-in user.
If this answer is helpful please mark correct and helpful!
Regards,
Christopher Perry
Regards,
Chris Perry