RE: SearchEngine and criterias
Hi Ummair
dealing with SearchEngine criterias can be annoying sometimes as it often requires a lot of trial and errors.
What I usually do when struggling with this is to use buildSql() function on the SearchEngine class to see what the output is.
For example, your SQL:
SELECT name from contact
WHERE (name = 'Ummair' AND email = 'umta@domain.com')
OR (name = 'Ummair' AND number2='1234')
could be translated to this in SearchEngine:
SearchEngine se;
se.addField("contact.name");
se.addCriteria("contact.name", "Equals", "Ummair", "And", 0);
se.addCriteria("contact.(Email->contact_id).email_address", "Equals", "umta@domain.com", "Or", 0);
se.addCriteria("contact.name", "Equals", "Ummair", "And", 1);
se.addCriteria("contact.number2", "Equals", "1234", "Or", 1);
Which would output:
select a0.name from contact a0 left join Email a1 on (a1.contact_id = a0.contact_id)
where (a0.name = ? and a1.email_address = ?)
or ((a0.name = ? and a0.number2 = ?))
Which looks like your query.
I'm no expert on grouping with SearchEngine, but my "go to" solution when wanting several groups is to increase the last integer in the SearchEngine (Priority), ref the documentation in CRMScript:
"Priority: A number. All criterias with the same number will be place inside the same brackets".
I advice you to test it out, do a print(se.buildSql()); to see that SQL query being generated and you should be able to get the results that you want.
Edit: See that Hans was a bit quicker than me to respond.