Skip to main content

Posts

Showing posts from August, 2023

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() {     ...