Filter contacts based on customer

anayna
Tera Contributor

I have a requirement where i need to filter the contacts based on customer.

my two fields on the table are customer,contact

customer is refrenced to account table 

and contact is refrence to customer_contact table.

 

i tried writing a script include but it is not fetching me the results:

var getContactCustomer = Class.create();
getContactCustomer.prototype = {
initialize: function() {
},
getContact : function()
{
var contact = new GlideRecord('customer_contact');
contact.addQuery('sys_id','account');
contact.query();
if(contact.next())
{
return "account"+"="+contact.customer.toString();
}

},
type: 'getContactCustomer'
};

 

i used the script include on the variable contact :javascript : new getContact().getContact()

8 REPLIES 8

AnubhavRitolia
Mega Sage
Mega Sage

Hi @anayna 

 

No need of Script Include. 

 

You can achieve it using Reference Qualifier also. Add below line in your advance Reference Qualifier:

 

javascript: 'account='+current.u_customer;

 

Update field names based on requirement.

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

i tried this but then it does fetch me the results but the total contacts in the table are not visible after filtration.

for eg-in contact table there are  41k records but after applying the reference i can see only 25k records

Hi @anayna 

 

Did you updated field name based on your instance?

 

What is the field name of your Customer field name? u_customer only right which refers to 'customer_account' table, right?

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

yes i did that also i can get the correct list but the records become less after the filtration i am not sure why is this hapenning