Filter Using Multiple Criteria on the Same Attribute
This example script on OpportunityVO shows how you can filter using multiple criteria on the same attribute. For instance, you can search with multiple conditions like "where value > 20 and value < 30" or "Opportunity Name starting with A".
You can use the below sample script to retrieve opportunity records with names that start with an A or AMMM.
You can't use ensureCriteriaItem() to set multiple conditions on the same field. If you use ensureCriteriaItem() to set multiple conditions,
only the last condition applies. So, instead of using two view criteria,
you can create two ViewCriteriaRow elements
on the same ViewCriteria.
println("Start ensureCriteriaItem test")
def vo = newView('OpportunityVO');
def vc = vo.appendViewCriteria("Name like 'A%' and Name = 'AMMM'")
vo.executeQuery();
while(vo.hasNext())
{
println("inside while")
def row = vo.next()
println(row.Name)
}
println("End ensureCriteriaItem test")