- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2015 07:45 AM
Hello all,
I am trying to filter one reference fields results based on another reference field. I found another post that worked for someone else, but that doesnt seem to work for me. ( javascript:'u_account_name='+ current.u_account_name;)
I have two tables, u_national_account_account_nam and u_national_account_tags.
u_national_account_tags has a reference field that looks at u_national_account_account_nam 's field called u_account_name.
On my Catalog item I have a field called "naCustName" that references my table u_national_account_account_nam. Later on in the request I have another field "naTagNumber" which references the 2nd table u_national_account_tags. I need that field to only display the tags that are associated with the customer that is listed in the "naCustName" field.
If anyone has any good advice on what I need to do would be appreciated!
Steve
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2015 10:41 AM
All,
I ended up finding a article on SN Guru called "Changing the filter on a list collector variable via client script"
My company decided to go with a list collector so they could pick multiple items. This worked, great, here is what I ended up with;
function onChange(control, oldValue, newValue, isLoading) {
//Apply a filter to the list collector variable
var collectorName = 'naTagNumber';
var filterString = 'name!=NULL^u_account_name='+g_form.getValue('naCustName');
//Find the filter elements
var fil = gel('ep');
//Reset the filter query
eval(collectorName + 'g_filter.reset()');
eval(collectorName + 'g_filter.setQuery("' + filterString + '")');
eval(collectorName + 'acRequest(null)');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2015 09:47 AM
You need to have a reference qualifier as : javascript:getMyQuery()
Now have a script include as:
Name : getMyQuery
Client Callable : True
Script :
function getMyQuery() {
var answer = '';
var includes = current.variables.naCustName;
var usr = new GlideRecord('u_national_account_tags');
usr.addQuery('<<ref_field>>',includes);
usr.query();
while (usr.next()) {
if (answer.length > 0) {
answer += (',' + usr.sys_id);
}
else {
answer = '' + usr.sys_id;
}
}
return 'sys_idIN' + answer;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2015 10:15 AM
Thanks Mani for the reply. I tried the script include as is and it didn't seem to work. I also thought maybe where you had listed <<ref_field>> that I should put in the reference field name (u_account_name) but that didn't seem to do it either.
As a side question, if the business decides they want to have the ability to do a list Collector instead (currently deciding which route, but starting to lean this way) and select mult "Tag Numbers", is there a way to still do a reference qualifier? (I don't see any options).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2015 10:41 AM
All,
I ended up finding a article on SN Guru called "Changing the filter on a list collector variable via client script"
My company decided to go with a list collector so they could pick multiple items. This worked, great, here is what I ended up with;
function onChange(control, oldValue, newValue, isLoading) {
//Apply a filter to the list collector variable
var collectorName = 'naTagNumber';
var filterString = 'name!=NULL^u_account_name='+g_form.getValue('naCustName');
//Find the filter elements
var fil = gel('ep');
//Reset the filter query
eval(collectorName + 'g_filter.reset()');
eval(collectorName + 'g_filter.setQuery("' + filterString + '")');
eval(collectorName + 'acRequest(null)');
}