Posts

Showing posts with the label Apex

LinkedIn

SOQL Injection - Demo and Approaches to Prevent it

Image
 In this post let us see a sample use case of SOQL Injection and the different methods to get rid of SOQL injection. 1. What is SOQL Injection? This will happen when we try to execute Dynamic Query in Apex, accepting input from the User. And the user can modify input value based on his need, thus resulting in unintended query results. 2. Sample Use Case We have got an LWC Component to Search for Accounts, accepting Account Name as the input parameter. On successful search, the component will display resulting accounts matching search criteria. Code Details below: accountNameSearch.html < template > < h1 > Search Account </ h1 > < lightning-card title = "Search Account Using Name" > < lightning-input label = "Enter Account Name" onchange = {handleFilter} class = "slds-size--2-of-8" ></ lightning-input > < br /> < lightning-button label = "SEARCH" onclick = {handleSearch...

Transaction Finalizers for Asynchronous Apex Jobs

Image
Transaction Finalizers are Generally Available from Summer 21 release. Let us see the features and how to implement Transaction finalizers in this blog post. 1. What is Transaction finalizers? The Transaction Finalizers feature enables you to attach actions, using the  System.Finalizer  interface, to asynchronous Apex jobs that uses the Queueable framework. The logic associated with Finalizer implementation will be executed once the asynchronous execution finishes.  2. Methods available for Finalizer Interface We can get below details of the executed job process in the finalizer Implementation: 3. Features of Transaction Finalizers 4. Implementation Details Use Case We want to execute 2 operations: 1. When ever a new contact is getting created/updated with Country field value, parent Account's Account country field should be appended with new country If Account ABC has 2 contact - Contact X with country India and Contact Y with country France, the Account Country in Accou...