Question: I'm attempting to create filters that will show certain types of contacts under the Contacts tab of an Account in SalesLogix.
I created a tab that only listed Contact type = Patient:
criteria.Add(ef.Eq("Account.
Id", account.Id.ToString()));
criteria.Add(ef.Eq("Type","Patient"));
I created a second tab, in an attempt to show all contacts that do not have the type
Patient, if the Contact type is listed as Null it will not be shown:
criteria.Add(ef.Eq("Account.Id", account.Id.ToString()));
criteria.Add(ef.Ne("Type","Patient"));
I added: criteria.Add(ef.Disjunction().Add(ef.IsNull("Type")));
This only returns a blank list. How do I add an "or" statement?
Answer: If you call iCriteria.Add(lExpression) successively it will combine all expressions with the AND junction, this is by default.
To combine a number of expressions with "or", use the IJunction interface:
Sage.Platform.Repository.
IJunction junction;
if (weWantToAndThisExpression)
{
junction = ef.Conjunction(); // AND
}
else
{
junction = ef.Disjunction(); // OR
}
ICriteria.Add(junction
.Add(ef.Eq("Account", account))
.Add(ef.Eq("IsPrimary", true)))
.List();
You can try something like this:
criteria.Add(ef.Eq("Account.Id", account.Id.ToString()));