How to use a variable in another variable reference qualifier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2014 01:40 AM
I have two variables variable1 and variable2 in a catalog item. variable1 is a choice field and variable 2 is a reference field.Is it possible to use variable1 value as a reference qualifier in variable2?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2014 01:49 AM
use a reference qualifier ...
it should be something like current.variables.variable1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2014 02:57 AM
javascript:if (current.variables.XYZXYZ != "") "YOUR_COLUMN=" + current.variables.XYZXYZ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2014 07:56 AM
If I understand correctly, the fields used in the reference qualifier have to already be populated when the form loads, or you won't get good results. So if you try to access a variable that is populated by a client script, it may be null when the reference qualifier tries to use it. By using a script include, it will do the work (a GlideRecord search, for example) as part of loading the variable. But if I'm off a bit, someone please correct me. I don't want to disseminate bad information, but that's how it seems to work to me.
I struggled with getting this to work by making it harder than it needed to be. I wanted to compare the NT id for the current user to a list I had in a table populated from Active Directory, and restrict that user from seeing any entries that they were not an administrator for. I ended up making a Script Include to build the query string like the following:
function fetchNTid() {
userid = gs.getUserID(); // fetches the current user
var user = new GlideRecord('sys_user');
user.get(userid);
ntid = user.u_windows_id; // fetches the NT id of the current user
answer = "u_adminsLIKE"+ntid+"^ORu_ou=ALL"; // build the query string
return answer; //return the query string
}
The 'u_admins' column holds the NT ids of people allowed to administrate each Org Unit, and I needed the 'ALL' to be an option too. So if my nt id is 'jpublic', then the resulting string returned to the reference qualifier is "u_adminsLIKEjpublic^ORu_ou=ALL". (I inserted ALL in the OU table, other entries are the names of the OU's in Active Directory.)
Then use the name of the Script Include in the Reference Qualifier of the Lookup Select Box with the "javascript:" prefix:
It was a lot easier than I was initially trying to make it, but I thought maybe the details and image would help someone else.