Tips for Formatting Longer Criteria Across Multiple Lines
Groovy does not allow carriage returns or newlines to appear inside of a quoted string, so for example, the following lines of script would raise an error:
def vo = newView('StaffMember')
// ERROR: Single-line quotes cannot contain carriage returns or new lines
vo.appendViewCriteria("
(Salary between 10000 and 24000)
and JobId <> 'AD_VP'
and JobId <> 'PR_REP'
and CommissionPct is null
and Salary != 11000
and Salary != 12000
and (DepartmentId < 100
or DepartmentId > 200)
")
vo.executeQuery()
Luckily, Groovy supports the triple-quote-delimited, multi-line string literal, so you can achieve a more readable long view criteria filter expression using this as shown:
def vo = newView('StaffMember')
vo.appendViewCriteria("""
(Salary between 10000 and 24000)
and JobId <> 'AD_VP'
and JobId <> 'PR_REP'
and CommissionPct is null
and Salary != 11000
and Salary != 12000
and (DepartmentId < 100
or DepartmentId > 200)
""")
vo.executeQuery()