Contents
When to use typeof in a soql query?
TYPEOF is used in a SELECT query to specify the fields to be returned for a given type of a polymorphic relationship. For example, you cannot use WITH SECURITY_ENFORCED in this query. The query specifies certain fields to be returned for Account and Opportunity objects, and Name and Email fields to be returned for all other objects.
When to use security enforced in soql select?
In other words, security is enforced on what the SOQL SELECT query returns, not on all the elements that go into running the query. After the WHERE clause if one exists, else after the FROM clause.
When to use typeof in a polymorphic query?
TYPEOF is only allowed in the SELECT clause of a query. You can filter on the object type of a polymorphic relationship using the Type qualifier in a WHERE clause, see Filtering on Polymorphic Relationship Fields for more details.
Are there any queries that do not use security enforced?
Traversing a polymorphic field’s relationship is not supported in queries using WITH SECURITY_ENFORCED. For example, you cannot use WITH SECURITY_ENFORCED in this query, which returns the Id and Owner names for User and Calendar entities: SELECT Id, What.Name FROM Event WHERE What.Type IN (’User’,’Calendar’).
When to use parent to child query in soql?
Parent to Child Queries (Inner Query) in SOQL An Inner Query is normally used when you want to retrieve the related child record for a particular parent record or set of parent records. For example, to pull the Contacts related to a particular Account, you can use the following SOQL query:
How to query the Salesforce database using soql?
Knowledge of the Salesforce Developer Console and Query Editor. You’ll be using the Developer Console to run these queries. Click Your Name. Select Developer Console. Click the Gear Icon. Select Developer Console.