Advanced reference qualifier based on Company
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2018 12:07 PM
Hi,
We are trying to filter using a reference qualifier CI's that belong to the company that the incident is opened by.
This is working using " javascript:'company='+current.company "
However, we want to add another qualifier where 'current.company.vendor!=true' - to not restrict the CI's if the company that the incident is opened by is a Vendor.
How can we achieve this easily? I tried with the below but could not get it to work.
javascript:if(company.vendor!=true^EQ){'company='+current.company}
Thanks
Alex
- Labels:
-
User Experience and Design
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2018 01:24 PM
If you just need to restrict Cis based on the company, you can directly do it based on the dependent field. thats how its configured OOB.
Since you have an additional condition here which is company.vendor!=true it needs a script include approach.
Reference qualifier would be javascript:new getCompanyCi().getCiList()
script include getCompanyCi
var getCompanyCi = Class.create();
getCompanyCi.prototype = {
initialize: function() {
},
getCiList: function() {
var returnString = 'sys_idIN' ;
var companyId = current.company +'';
var queryString = 'company=86c1f3193790200044e0bfc8bcbe5d95';
var grCi = new GlideRecord('cmdb_ci');
grCi.addQuery('company', companyId);
grCi.addQuery('company.vendor', '!=', true);
grCi.query();
while(grCi.next()) {
returnString += grCi.sys_id + ',';
}
return returnString;
},
type: 'getCompanyCi'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2018 01:00 AM
Try to use
javascript: "company=" + current.company + "^company.vendor!=true"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2018 01:58 AM
Try the following reference qualifier:
javascript: current.company.vendor!=true ? "company=" + current.company : ""
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2018 10:41 AM
Dear Olegki,
This solution works for happy path which is, if the company is not a vendor, then it shows all the CIs that belong to the company. But if the company is a vendor then no records should be available, but since the false condition says
javascript: current.company.vendor!=true ? "company=" + current.company : ""
In order to make it work in all cases it should be
javascript: current.company.vendor!=true ? "company=" + current.company : "sys_id == ''"
Thanks
Anil