Query on Relationship

devservicenow k
Tera Contributor

Requirement is to Display all the Emails From Incident and Case table to display in the Related list of Case Record.

So i have created a Relationship in case table.

 

But i am Not able to get the Correct Output, do i need to add any additional query

help me with script .

1 ACCEPTED SOLUTION

Muhammad Khan
Mega Sage

If you are looking for all emails on the incident and case table, then use below statement.

current.addQuery('target_table', parent.sys_class_name).addOrCondition('target_table', 'incident');

 

If you are looking for emails only on current record, then use below statement.

current.addQuery('instance', parent.sys_id);

 

If you are looking for emails on current record along with the emails on incident table, then use below statement.

current.addQuery('instance', parent.sys_id).addOrCondition('target_table', 'incident');

View solution in original post

3 REPLIES 3

PavanK960672992
Mega Patron

Hi @devservicenow k ,

Try below query.

current.addQuery("target_table", parent.sys_class_name);
current.addQuery("instance", parent.sys_id);

Muhammad Khan
Mega Sage

If you are looking for all emails on the incident and case table, then use below statement.

current.addQuery('target_table', parent.sys_class_name).addOrCondition('target_table', 'incident');

 

If you are looking for emails only on current record, then use below statement.

current.addQuery('instance', parent.sys_id);

 

If you are looking for emails on current record along with the emails on incident table, then use below statement.

current.addQuery('instance', parent.sys_id).addOrCondition('target_table', 'incident');

Anil Lande
Kilo Patron

Hi,

Which field on Case refer to incident?

Do you want all emails related with incidents (All) or any particular incident which is related with Case?