I want to get all contactinterests from a contact with interest name and heading.
How do I use the search engings dot-syntax to join the necessary tables?
In SQL I would write something like this:
select a0.cinterest_idx,a1.name,a1.ContInt_id , a2.heading_id, a3.name
from CRM7.CONTACTINTEREST a0
left join CRM7.CONTINT a1 on (a1.ContInt_id = a0.cinterest_idx)
left join CRM7.CONTINTHEADINGLINK a2 on (a2.contint_id = a0.cinterest_idx)
left join CRM7.HEADING a3 on (a3.heading_id = a2.heading_id)
where (a1.deleted = 0 and a0.contact_id = 141 )
All Replies (1)
Since these table/field relations are known in data dictionary you can join them easily using the dot syntax, sample:
SearchEngine seContactInterests;
Integer contactId = 19;
seContactInterests.addField("contactinterest.contactinterest_id");
seContactInterests.addField("contactinterest.cinterest_idx");
seContactInterests.addField("contactinterest.cinterest_idx.name");
seContactInterests.addField("contactinterest.cinterest_idx.(ContIntHeadingLink->contint_id).heading_id");
seContactInterests.addField("contactinterest.cinterest_idx.(ContIntHeadingLink->contint_id).heading_id.name");
seContactInterests.addCriteria("contactinterest.contact_id", "OperatorEquals", contactId.toString());
seContactInterests.addCriteria("contactinterest.cinterest_idx.deleted", "OperatorEquals", "0");
print(seContactInterests.executeHTMLTable());