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
lokesh reddy 7lokesh reddy 7 

Need help in select query

Hi ,

Iam trying query all the engagement products except except one product with name contains 'Exclude Producr'

lstEngageProduct = [Select Id, CurrencyIsoCode, Name, FTE__c,Available_FTE_s__c, Product__r.Name, Quantity__c, Total_Price__c, Engagement__c from Engagement_Product__c   where Engagement__c =: ApexPages.currentPage().getParameters().get('Id')  AND NOT((Product__r.Name).contains('Exclude Producr'))  ];

But iam getting error ,Can some one help me  on this to exclude the product.

Thanks
Lokesh
UC InnovationUC Innovation
Try to query the other way.  Query for the products where the name is not equal to 'Exclude Producr'' and engagement is equal to the ID.
UC InnovationUC Innovation
In your original query, you can't use:

NOT((Product__r.Name).contains('Exclude Producr'))

since Product__r is a related list.
Fabio PalladinoFabio Palladino
Hi Lokesh,
I think you can use the "LIKE" operator with NOT logic in SOQL query:

...... AND (NOT Product__r.Name LIKE '%Exclude Producr%') ....

Try and let me know