I have a batch class where I need to find all contacts with titles like director, cEO, etc. This should allow partial matches such as 'support director', 'sales director', I was trying this but is not returning the contacts. Is there any other way other than adding a bunch of OR conditions?
String[] VIPTITLES = new String []{'\'%CEO%\',\'%CFO%\',\'%CMO%\',\'%CTO%\',\'%CIO%\',\'%COO%\',\'%VP%\',\'%DIRECTOR%\',\'%VIP%\''};
query = 'Select Id FROM CONTACT WHERE Contact.Title LIKE : VIPTITLES'
Best Answer
You can build your query by looping through each title instead:
The query will now be:
With all titles being a separate LIKE.
If you fill in no VIPTITLES it will return: