- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 03:30 AM
Hi All,
I have two variables in my record producer:
1. Customer(this is a reference field)
2.SOF(this is list collector)
I need to create a filter on the "SOF " field on the record producer form so that it only shows SOF records that are associated with the same Company that the record is for. So if the "Customer" field on the record producer form is set to "XYZ", then only SOF records where the "Company" field on the SOF record EQUALS "XYZ" should be displayed for the user to choose from.
Please let me know how I can achieve this.
Regards,
Shugufta.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 03:50 AM
Hi Shagufta,
Please use the updated code :
""
I advice to use an onChange client script which would set the filters to you. The list collector has to refer the right table for records. I had a catalog item where i have used this code,
I would request you to implement something similar(this is a catalog client script):
var collectorName = 'list_collector_field_name'; // the list collector field on the record producer
var filterString = 'group='+g_form.getValue(' field_name '); // from where the filter is dependent on the record producer
//Hide the list collector until we've set the filter
if(typeof(window[collectorName + 'g_filter']) == 'undefined'){
setTimeout(setCollectorFilter, 100); //Test if the g_filter property is defined on our list collector.
//If it hasn't rendered yet, wait 100ms and try again.
return;
}
window[collectorName + 'g_filter'].reset(); // this resets
window[collectorName + 'g_filter'].setQuery(filterString); //sets the filter
window[collectorName + 'acRequest'](null); //runs the filter automatically
once its populated it can fetched later in RITM and TASKs.
""
The default values of the list collector should not have no_filter , and as the client script does the task script include and calling script include can be excluded too.
Do reach back if you get struck.
Regards,
Shariq
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 05:09 AM
Hi Shagufta,
I advice to use an onChange client script which would set the filters to you. The list collector has to refer the right table for records. I had a catalog item where i have used this code,
I would request you to implement something similar:
g_form.getReference('grp_name' ,test); // my custom field on which the changes are noted.
var collectorName = 'sel_user_remove'; // the list collector field
var filterString = 'group='+g_form.getValue('grp_name');
//Hide the list collector until we've set the filter
if(typeof(window[collectorName + 'g_filter']) == 'undefined'){
setTimeout(setCollectorFilter, 100); //Test if the g_filter property is defined on our list collector.
//If it hasn't rendered yet, wait 400ms and try again.
return;
}
window[collectorName + 'g_filter'].reset();
window[collectorName + 'g_filter'].setQuery(filterString);
window[collectorName + 'acRequest'](null);
Just try to build the right query it should be fine.
Regards,
Shariq
Mark helpful if it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 08:01 PM
Hi Shariq,
So the grp_name is the variable and test is the name of the group?
I donot have any particular company name here it should work dynamically. When ever company is selected the SOF tickets associated should be generated in list collector.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 01:51 AM
Hi Shagufta,
Please ignore the test variable, as i told its a part of my long code , with test i was calling an function later. yeah it should work just check your queries..
Regards,
Shariq
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 01:59 AM
Hi Shagufta,
Did you get a chance to test my suggestions.
Regards,
Shariq

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2017 12:39 AM
Hi Shagufta,
You can call a script include using Advance reference qualifier, I will give this as an example for your understanding and please take this as a reference to fulfill your requirement.
I have a record producer with two fields one is reference (Field name: Model) and another one (Field name: Model List) is list type. (See below)
Please configure the dictionary of Model List.
with below reference specification.
Please find more details of advanced reference qualifier here: http://wiki.servicenow.com/index.php?title=Reference_Qualifiers#Advanced_Reference_Qualifier_Example
JavaScript call is the following code:
javascript:new GetListValue().getList()
This code calls a function named getList() in a script include named GetListValue(). The function must return a query string that can filter the options available on a reference field.
Please create a script include.
var GetListValue = Class.create();
GetListValue.prototype = {
initialize: function() {
},
getList : function()
{
var ids = [];
var gr = new GlideRecord('cmdb_model');
gr.addQuery('manufacturer', current.model.manufacturer);
gr.query();
while(gr.next())
{
ids.push(gr.sys_id.toString());
}
return 'sys_idIN' + ids;
},
type: 'GetListValue'
};
Now, you will get the lists populated in Model List field based upon the Manufacturer of Model field. (Please get the more details of Manufacturer, Model etc. from cmdb_model table [cmdb_model_list.do]).
Hope this helps you to find a path further.
manufacturer