- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2016 03:42 PM
I have two variables on a catalog item. 'name' and 'position'. The idea is that position is populated with all of the positions a person holds within the organisation when the name of the person is selected. This works absolutely fine using reference qualifier and variable attributes except for one vital detail:
When I load the form the name gets populated with a default value (gs.getUserID();) but the second variable (position) doesn't populate with anything. If I change the name variable to something else and back again position populates fine - it's as if the position variable is referencing the name variable before it is populated.
I have scoured the forums and can find no-one else suffering this problem, but I can't see how variable attributes: ref_qual_elements=name is of any use to make a dependent field if it doesn't fire onLoad.
Help would be appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2016 04:59 PM
Well - I have a solution but it still seems to me to be a big flaw in the platform:
If I write a script include that does exactly the same things as my old reference qualifier (javascript:'u_employee='+current.variables.name):
Then add a clause to capture the occurance of 'name' being undefined (the onLoad) - it works fine (if a huge sledgehammer to crack a badly implemented event handler!):
function u_getPositionsForCurrentUser() {
if (JSUtil.nil(current.variables.name)){
user = gs.getUserID();
}else{
user = current.variables.name;
}
var answer = '';
var grUser = new GlideRecord("sys_user");
grUser.get("sys_id", user);
var positions = new GlideRecord('u_ccc_position');
positions.addQuery('u_employee', grUser.sys_id);
positions.query();
while (positions.next()) {
if (answer!="") {
answer += ',' + positions.sys_id.toString();
}
else {
answer = positions.sys_id.toString();
}
}
return 'sys_idIN' + answer;
}
and call it in the reference qualifier: javascript:u_getPositionsForCurrentUser();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2016 03:47 PM
reference qualifiers are just used to filter the data you see based on some conditions. In your case, you will need an onLoad and onChange client script for this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2016 04:04 PM
Thanks
So you mean I need to do an onLoad that gets the value of the user variable (I presume g_form.getValue('name') and then does a full round trip back to the server to query the position table for an employee that matches the name variable user object and then manually adds all of the options to the select box just so that they show on load, when I have a reference qualifier specified to do just that - it just doesn't fire onLoad.
This doesn't make any sense...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2016 04:12 PM
I got you. I have misunderstood your requirement. So you want to filter the look up select box based on the name variable right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2016 04:22 PM
Yes - and it works fine if I change the name (it is a lookup select box itself) and change it back it populates the position lookup select box but it won't do it onLoad (event though the name variable is set).