The CreatorCon Call for Content is officially open! Get started here.

How do I compare two reference field value?

Sid_Takali
Kilo Patron

Hi all,

I have a scenario where I have to create Relationship in two tables (Related List). Applies to table is "Case" and Queries from table is "Custom" Table. There is a common reference field in both the table and that refers another table. So how do I compare a reference field from "Case" Table and "Custom" table. 

 

Thanks

1 ACCEPTED SOLUTION

Hi @Sid_Takali ,

Yes I got it. You have the case table and custom table. custom table the case reference field and case table has the custom table field.

we can display related data on custom table which is using on case and vice versa.

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

View solution in original post

6 REPLIES 6

Omkar Ranjane
Tera Guru

Hi @Sid_Takali 

 

Lets say field name on custom table is "u_parent" which refer the case record.

 

Applies to table [Select the table on which the related list appears] : Case

Queries from table [Select the table from which this related list retrieves data] : Custom

Query with : current.addQuery('u_parent', parent.sys_id.toString()); // here parent means Applies to table

 

If your question is solved, please close the topic by marking my answer "Accept as Solution". This will help others searching for a similar question and will remove the topic from the unsolved list.

Muhammad Khan
Mega Sage

Try with below script.

(function refineQuery(current, parent) {

	// Add your code here, such as current.addQuery(field, value);
	current.addQuery('common_reference_field_backend_name', parent.getValue('common_reference_field_backend_name'));

})(current, parent);