function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vrdevvrdev 

"Does Not Contain" operator help

Our app provides query functionality against the Lead and Contact objects, similar to the "Create a new view" mechanism in salesforce.com. We are looking for a way to include an operator for "does not contain" but it appears that the API documentation does not provide information to make this happen.

Does anyone know of a way to handle this, short of pulling all data first and then excluding everyone that falls into the "contains" collection?
ScotScot
Assuming you're using SOQL to query the records, try ... not like ... as in:
 
    Select Id, LastName from User where not LastName like '%a%'
 
which returns all the users that do not contain 'a'.
vrdevvrdev
Thanks Scot, this worked. Our developer just had make a minor adjustment and all is good - appreciate the help.
Anand SinghAnand Singh

Hi Scot,

 

The SOQL does not work if we add additional criteria in the statement as follows:

 

Select Id, LastName from User where  not LastName like '%a%' and city != null

OR

Select Id, LastName from User where city != null and  not LastName like '%a%' 

 

It seems like it Is not supported in SFDC.