Skip to main content

Posts

Showing posts from June, 2019

WITH SECURITY_ENFORCED - Spring '19

Use the  WITH SECURITY_ENFORCED  clause to enable checking for field- and object-level security permissions on SOQL  SELECT queries, including subqueries and cross-object relationships. Although performing these checks was possible in earlier releases, this clause substantially reduces the verbosity and technical complexity in query operations. This feature is tailored to Apex developers who have minimal development experience with security and to applications where graceful degradation on permissions errors isn’t required. To use, just add the  WITH SECURITY_ENFORCED  clause in SOQL  SELECT  queries. If there are any fields or objects referenced in the  SELECT  clause that are inaccessible to the user, an exception is thrown and no data is returned. If field-level security for either the  LastName  or  Description  field is hidden, this query throws an exception indicating insufficient permissions. SELECT Id, (SELECT LastName FROM Contacts),    (SELECT Description FROM Oppor

Asynchronous Apex Triggers - Summer ‘19

Asynchronous Apex triggers are change event triggers that run asynchronously after a database transaction is completed. They are ‘after-insert’ triggers and can be defined with the  after insert  keywords. They can be created the same way you create regular Apex triggers. You set the trigger to use a change event object instead of an sObject. The change event object na me is suffixed with  ChangeEvent . For example, Account change event object is named  AccountChangeEvent . The change event object name for the custom object is suffixed with  __ChangeEvent . How does it work? When a record is created or updated, Change Data Capture publishes an event and a change event trigger can then process that event asynchronously. Let’s look at an example transaction. Whenever an opportunity record is created or updated, you need to check whether the corresponding account is qualified to be a high priority customer. This process of qualifying high priority customers is very limit-intensiv