Tag: SOQL
-
How to Exclude Keywords in SOQL?
Question I need to write a SOQL query in Power Automate that retrieves the IDs of Cases where the comment text does not contain specific keywords. Specifically, I want to exclude cases where the comment includes any of these words: “freigabe”, “Freigabe”, or “DocCheck_approved”. However, my current attempt does not work as expected. Instead of…
-
Why Is My Apex Sharing Rule Not Granting Record Access?
Question I am trying to share Project__c records with the Project Management Team public group when Priority__c is set to “High” using an Apex sharing rule. To achieve this, I created an Apex Sharing Reason called Project_Sharing_Rule and implemented the following trigger and helper class: Trigger Code Apex Class Code Answer The error occurs because…
-
Efficient Pagination in SOQL Queries with the 2,000 Row OFFSET Limit
Question What is the most efficient method to implement pagination in SOQL queries, considering the 2,000 row OFFSET limit? Answer In Salesforce Object Query Language (SOQL), the OFFSET clause allows you to skip a specified number of rows in the returned data, facilitating pagination. However, there’s a limitation: the maximum OFFSET value is 2,000 rows.…
-
Can LIKE Be Used with a List in SOQL?
Question Is there a way to use the LIKE operator with a list of values in SOQL, similar to how we use IN? For example, can we write a query like this: Where nameList is a list of strings? Instead of dynamically constructing a query with multiple OR conditions, is there a more elegant way…
-
How to Query Polymorphic Fields in SOQL?
Question: When working with polymorphic fields like Owner or What in Salesforce, which can reference multiple object types, how can I construct a SOQL query that avoids errors when querying fields that may not exist on all possible related objects? For example, if I query the Owner field and include fields specific to User or…