Filter contacts based on customer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2022 02:09 AM
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()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2022 02:27 AM
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.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2022 02:32 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2022 02:36 AM
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?
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2022 02:37 AM
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