Posts

Child to parent component communication in lwc

Image
     An application composes multiple lighting web components, and we frequently want those components to share the information. A component inside another component creates the Parent and child relationship. How a parent communicates with a child is different from how a child communicates with its parent. Sharing information between the LWC components is simple by using the custom events. There are 3 types of communication, Child to parent  Parent to child Unrelated Components communication In this section, we will see how to communicate from child to parent. childLwc.html < template > < lightning-input onchange = {handleChange} type = "number" name = "input1"      label = "Enter a number" ></ lightning-input > </ template > childLwc.js In the child component, we will create and dispatch the event by passing the information in the form of the JSON structure. import { api , LightningElement } from 'lwc' ; expo

How to clone a record using custom button in salesforce

Image
USE CASE  A user wants to create new records by mirroring the existing records with minimal clicks using the “Button” (Cloning the records). SOLUTION  Create the custom button where all the user-requested fields will be mapped. Add created a custom button on the page layout. Create a Custom Button  Go to Setup  - Object - Buttons, Links, and Actions Section -- Click New button or Link ->  Enter Label Name(Account Transfer) Select Display Type as “Detail Page Button” and Content Source as “ URL ” Add all the user-requested fields with their IDs and add the  return URL  with the Object id. If the field is Lookup, Prefix  CF  with field id (See the below Image) Finally  Save  all the works you did. 6.       Add created “ Custom Button ” on the Page Layout. 7.            When Clicking on the “ Account Transfer ” Button, Whatever the mapped fields in the button will populate from the existing record. (Highlighted in orange color) 8.            Click the “ Save ” button and save the recor