0

I have a requirement where i have written a Query to fetch the records from the Server. I want to modify it as per the business requirement not to include the certain records, Please help me out for this .

{` testobj = [
                SELECT Id, Cust__c, C_R_Role__c, Rest_Flag__c, FTest__c, Web__c, Type__C
                FROM testObj__c
                WHERE Customer__c = :cReocrdId
                WITH SECURITY_ENFORCED
                ORDER BY Rest_Flag__c ASC NULLS LAST
            ];`}

i want Type__c in Which there are two record ABC__c and DEF__c should not be included in the above query can anyone help me out with the above requirement.

Thanks

3
  • You can use != and not in in SOQL and use and to combine multiple conditions. See developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/… and the following pages.
    – Keith C
    Apr 28, 2020 at 7:56
  • Hi Ramrahul, Is ABC__c and DEF__c are fields on the same retrieved record or are they constants?
    – Lior Lavi
    Apr 28, 2020 at 7:56
  • They are values stored in the Type__c field which is being retrieved in the Query
    – Ramrahul
    Apr 28, 2020 at 7:59

1 Answer 1

1

You can try below query

[SELECT Id, Cust__c, C_R_Role__c, Rest_Flag__c, FTest__c, Web__c, Type__C
                FROM testObj__c
                WHERE Customer__c = :cReocrdId
                AND Type__c NOT IN ('ABC__c', 'DEF__c') 
                WITH SECURITY_ENFORCED
                ORDER BY Rest_Flag__c ASC NULLS LAST
            ];

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .