Active=true in Reference Qualifier

Kri
Tera Guru

I want to add additional condition active=true in my existing script in the reference qualifier for the Variable 'Line Manager', I tried adding the below script but it is not working, Can you help me where I'm going wrong?

javascript: "company=" +current.variables.company^active=true

Krishna124_0-1683010989169.png

 

15 REPLIES 15

Kartik Choudha1
Tera Guru

Hi @Kri 

 

could you try this. If company is empty, it should not show anything to it

KartikChoudha1_0-1683021887633.png

 

For additional query condition, active = true. - Could you let me know once the backend names of Company field and active field. Just to cross check.

If backend names are - 'company' and 'active' only

 

yes it is  'company' and 'active' only

then the below query should definitely work. Something else is fishy. Try putting the records as active- false and then test it. 

 

javascript: if(current.variables.company != "") "company="+current.variables.company+"^active=true"

 

This didn't works, it is still giving full values

Then you can call the Script Include method from reference qualifier and in the function do the GlideRecord to 'customer contact' table with the same query in addEncodedQuery().

 

Reference qualifier-

 

 

javascript: new ScriptIncludeName().getCustomerContacts(current.variables.company);

 

 

Create a new Script include-

 

 

function: getCustomerContacts(vCompany){

var arrSysIds = []; // array to store the records
var grCustomerContact = new GlideRecord('customer_contact');
grCustomerContact.addQuery('company',vCompany.toString());
grCustomerContact.addActiveQuery(); //queries only active record, you can write grCustomerContact.addQuery('active',true);

grCustomerContact.query();
while(grCustomerContact.next()){
arrSysIds.push(grCustomerContact.sys_id.toString());
}

return arrSysIds.toString();
}

 

 

 

It should solve this issue. I didn't run the code but it should work. Let me know if it gives any error

 

You can try one more thing for testing purpose, just put the condition as Active is True in simple reference qualifier and see if it is giving only active records in reference field.