Advanced reference qualifier based on Company

alexfossa
Tera Contributor

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

 

5 REPLIES 5

VaranAwesomenow
Mega Sage

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'
};

Oleg
Mega Sage

Try to use

javascript: "company=" + current.company + "^company.vendor!=true"

Oleg
Mega Sage

Try the following reference qualifier:

javascript: current.company.vendor!=true ? "company=" + current.company : ""

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