Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Spring 23 for Developers

Spring 23 for Developers

Spring 23 enhancements and new features for the Spring 23 release of Salesforce. Presented at the London Salesforce Developers Trailblazer group meetup in April 2023.

Keir Bowden

April 20, 2023
Tweet

More Decks by Keir Bowden

Other Decks in Technology

Transcript

  1. LWC References Access HTML element via a reference • HTML

    <template> <div lwc:ref="userInfo"> ... </div> </template> • JavaScript let userInfoEle=this.refs.userInfo;
  2. LWC References String literals only • No dynamically generated names

    :( Cannot use in for:each or iterator LWC1158: Invalid lwc:ref usage on element "<li>". lwc:ref cannot be used inside for:each or an iterator. Can have multiple elements with identical references <div lwc:ref="userInfo"> … </div> <span lwc:ref="userInfo">… </span> ← Winner!
  3. Benefits over data-* attributes • Clarity - clear purpose to

    provide a reference • Hygiene - refs do not appear in rendered HTML • Performance ◦ this.refs built once by the platform ◦ Not evaluating selector across all objects LWC References
  4. •lwc:if •lwc:else •lwc:elseif Use in preference to if:true, if:false •

    More performant • Old versions will be deprecated and removed in future LWC Conditional Directives
  5. lwc:elseif and lwc:else must be immediately preceded by lwc:if or

    lwc:elseif LWC Conditional Directives <template lwc:elseif={sayGoodbye}> Goodbye! </template> <div>World!</div> ← Error! <template lwc:else> Nothing to say! </template> <template lwc:if={sayHello}> Hello World! </template> <template lwc:elseif={sayGoodbye}> Goodbye World! </template> <template lwc:else> Nothing to say! </template>
  6. Apply security of logged in user • Sharing rules (regardless

    of class sharing keywords) • Field Level Security • Object Permissions Use over WITH SECURITY ENFORCED • Handles polymorphic fields (Owner, TaskId) • Applies to all clauses (including WHERE) • Finds all errors in query (security enforced only returns first) User Mode Database Operations GA
  7. User Mode Database Operations GA SOQL WITH clause List<Contact> contacts=[select

    id, FirstName from Contact WITH USER_MODE]; DML as user Account acc=new Account(Name=’Buzzard, inc’); insert as user acc;
  8. User Mode Database Operations GA Can specify system mode List<Contact>

    contacts=[select id, FirstName from Contact WITH SYSTEM_MODE]; ... insert as system acc; Cannot elevate to system mode where user mode enforced • Anonymous Apex
  9. Specify delay when enqueing job System.enqueueJob(new CheckForResults(), 5); Delays job

    execution by 5 minutes Range : 0-10 minutes Configure org-wide default delay for enqueued jobs • Setup -> Apex Settings • 1-600 seconds Doesn't override delay parameter on enqueueJob Delay Enqueued Job GA
  10. Dynamic SOQL supports simple binds (primitives) with local scope Database.queryWithBinds

    supports bind variables. • Fields from sObjects • Results from method calls • Static variables Map acctBinds = new Map{'acctName' => new AccountService().defaultAccountName}; List accts = Database.queryWithBinds('SELECT Id FROM Account WHERE Name = :acctName', acctBinds, AccessLevel.USER_MODE); SOQL Query with Bind Variable Map
  11. Handles dotted names in query SOQL Query with Bind Variable

    Map • Badly! Map<String, Object> params = new Map<String, Object> { 'recordId' => '0018000001bLUTVAA4' }; String query = 'SELECT Id, Name FROM Account WHERE Id = :any.prefix.you.like.recordId' ; List<Account> accounts = Database.queryWithBinds(query, params, AccessLevel.USER_MODE);