- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2017 07:18 AM
I am trying to create a Dynamic Reference Qualifier and not having much luck.
(Personal development instance - Helsinki latest patch)
The objective is - on a Task Form - e.g. Incident -
select a "Company" value -
and then use a dynamic filter on the "Business Service" search pop-up to restrict choices to only those services that have their company attribute set to the same value.
My Script Include: (as you can see - I tried various ways to get the company value)
My Dynamic Filter
My Dictionary entry
I have tried lots of permutations but nothing seems to work
Any clues, hints, tips would be most welcome
Best Regards
Kevin
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2017 09:23 AM
Actually.. if you're just trying to filter based on the current company, you don't have to run a lookup script at all.
In your dynamic qualifer, you can just have this one line:
return "company=" + current.company;
When this is the case, I prefer to simplify the whole thing and use an "advanced" reference qualifier instead of dynamic:
javascript:"company=" + current.company
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 12:43 AM
THIS seems to be the issue -
This works and the Services are correctly filtered.
gr.addQuery('company', current.company);
These all cause the script to abort and no filtering is performed
gr.addQuery('company', 'ACME');
gr.addQuery('company', '=', 'ACME');
gr.addQuery('company', 'LIKE', 'ACME');
My suspicion is that task.company is a reference field - and thus matches the data type of current.company
Whereas 'ACME' is a String - and thus does not ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 02:21 AM
So the final solution seems to be:
var getServicesForCompany = Class.create();
getServicesForCompany.prototype = Object.extendsObject(AbstractAjaxProcessor, {
mygetServicesForCompany : function() {
var gr = new GlideRecord('cmdb_ci_service');
gr.query();
var services=[];
var s = "";
while(gr.next()){
s = gr.company.getDisplayValue();
if(s == "ACME"){
services.push(gr.sys_id + '');
}
}
return "sys_idIN" + services.join(",");
},
type: 'getServicesForCompany'
});
Call as Dynamic with
new getServicesForCompany().mykevGetServicesForCompany();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 02:21 AM
oops
Call as Dynamic with
new getServicesForCompany().mygetServicesForCompany();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 06:02 PM
Hey Kevin,
Can I jump in and ask if you had a requirement to pass in the company name/current to the function instead of using a static value 'ACME'? I want to compare the company on the parent form (Incident in my case) to "s" in your example.
I am trying to do something like this which doesn't seem to work.
var getServicesForCompany = Class.create();
getServicesForCompany.prototype = Object.extendsObject(AbstractAjaxProcessor, {
mygetServicesForCompany : function(grRec) {
var gr = new GlideRecord('cmdb_ci_service');
gr.query();
var services=[];
var s = "";
while(gr.next()){
s = gr.company.getDisplayValue();
if(s == grRec.company){
services.push(gr.sys_id + '');
}
}
return "sys_idIN" + services.join(",");
},
type: 'getServicesForCompany'
});
Call as Dynamic with
new getServicesForCompany().mykevGetServicesForCompany(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2017 12:46 PM
Did you confirm that my first suggestion/fix is in place?
Script in "dynamic" qualifier needs to change to:
new kevGetServicesForCompany().mykevGetServicesForCompany()