Skip to main content

Posts

Shallow Clone Vs Deep Clone in LWC !!

  Are you acquainted with the concept of shallow and deep cloning within Lightning Web Components (LWC)?  Shallow cloning involves crafting a fresh object that retains the same reference as the original, whereas deep cloning entails c rafting a novel object with an entirely new reference . 👉 Why does this matter? Well, imagine having an object with nested attributes, and you wish to modify one of these attributes without impacting the original object. Opting for shallow cloning means that any adjustments made to the nested attribute will likewise manifest in the original object. However, by embracing deep cloning, you can alter the nested attribute without influencing the source object. 💻 When working with LWC, you can utilize the spread operator to execute shallow cloning, and resort to the JSON.parse/JSON.stringify technique to achieve deep cloning. 👨‍💻 Grasping the distinction between shallow and deep cloning is crucial for ensuring accurate object updates, while side...

Sharing records by Apex in Salesforce

  Greetings, everyone! In today's session, we'll delve into the topic of sharing records within an Apex class. As we're aware, there exist various methods through which we can accomplish the sharing of records. We engage in record sharing primarily when the object's Organization Wide Default (OWD) settings are set to private. Sharing settings come into play when certain predefined criteria are met, allowing us to extend access to records to designated groups or roles. In cases where intricate logic is involved, manual sharing is employed. While this approach proves beneficial for specific records, instances where a multitude of records require automated handling, Apex sharing becomes the preferred solution. Salesforce offers a 'Share' object for each type of object, with distinct naming conventions: For standard objects, it's 'StandardobjectName+Share', such as 'AccountShare' for the 'Account' object. Custom objects follow the pattern...

Top 30 Database Methods in Salesforce

  Salesforce is a powerful CRM (Customer Relationship Management) platform that provides a wide range of database methods to manage and manipulate data. Here's a list of 30 important database methods and functionalities within Salesforce: SOQL (Salesforce Object Query Language): Query language used to retrieve records from Salesforce objects. SOSL (Salesforce Object Search Language): Search language for performing full-text searches across multiple objects. DML (Data Manipulation Language): Manipulate data in Salesforce using methods like insert, update, delete, and undelete. Database Triggers: Automate actions before or after specific data events (insert, update, delete). Record Types: Create different data entry layouts and business processes for different user profiles. Custom Indexes: Improve query performance by creating custom indexes on fields. Workflow Rules: Define automated processes to trigger actions based on data changes. Approval Processes : Automate and streamlin...

Generate File Download URL Using LWC

  Introducing generateUrl for Lightning Web Components. Easily generate and return a URL for downloading files in Experience Cloud. With the generateUrl function, you can retrieve a URL for downloading files within your Lightning Web Runtime (LWR) site. Syntax: import { generateUrl } from "lightning/fileDownload"; const url = generateUrl(recordId); window.open(url); Parameters: recordID (Required): The record ID of the file (ContentDocument, ContentVersion, Attachment, or Document) you want to download. Returns: A URL that allows you to download the specified file. Usage: Authenticated users can download files they have proper access to. Guest users can download ContentDocument files only if they have access via Library membership. Sample Code: import { LightningElement } from "lwc"; import { generateUrl } from "lightning/fileDownload"; export default class Download extends LightningElement {     recordId;     url;     handleClick() {     ...

Enable reactivity in lwc:spread (LWC)

With the introduction of Salesforce Summer '23 release, a new feature for LWC components called lwc:spread became available. This feature enables us to spread properties on child components. Although the documentation provides instructions on its usage, ensuring the spread feature's reactivity is essential to fully leverage its capabilities. In this article, we will delve into examples of a parent component and a nested child component to grasp how to achieve reactivity for maximum usability. The lwc:spread directive allows accepting a single object with key-value pairs, where the keys represent property names. In the example below, we demonstrate how to use this feature to spread properties on child components: <!-- app.html --> <template>     <c-child lwc:spread={childProps}></c-child> </template> In this case, the parent component sets an object called "childProps" with properties "name" and "country" having values...

Batch Apex Limitations

  Below are some important considerations to bear in mind when utilizing batch Apex: Concurrent Job Limitation: The maximum number of batch jobs that can be queued or active simultaneously is 5. Flex Queue Capacity: The Apex flex queue can accommodate up to 100 batch jobs in a holding state. Test Execution Limit: During a running test, a maximum of 5 batch jobs can be submitted. Method Execution Threshold: Within a 24-hour period, the total number of batch Apex method executions is capped at 250,000. However, if the product of the number of user licenses in your organization and 200 exceeds 250,000, then that becomes the limit. This includes the start, execute, and finish methods of batch Apex, along with other asynchronous Apex features such as Queueable Apex, scheduled Apex, and future methods. To check the available asynchronous Apex executions, you can make a request to the REST API limits resource. License Types Considered: The method execution limit encompasses full Salesforc...

Top 10 Most used Salesforce APIs

  Salesforce provides a comprehensive set of APIs (Application Programming Interfaces) that allow developers to interact with Salesforce's platform and services programmatically. These APIs enable developers to integrate Salesforce functionality into their own applications, automate processes, retrieve and manipulate data, and perform various operations. Here are some of the key Salesforce APIs with brief explanations and examples: REST API: The REST API is a widely used API in Salesforce and provides a lightweight and modern approach to interact with Salesforce resources. It supports CRUD operations, querying, searching, executing custom actions, and accessing various Salesforce features. Example: You can use the REST API to create a new Account record by making an HTTP POST request to the /services/data/vXX.X/sobjects/Account endpoint with the required fields. SOAP API: The SOAP API is a robust API that uses the SOAP protocol to integrate with Salesforce. It supports CRUD operat...