render() and renderedCallback() in LWC

# render() This function used for conditional rendering and use to override the standard rendering functionality. This function get called before and after connectedCallback(). render() must return a valid HTML template. render() method is not part of lifecycle hook but its a protected method on the LightningElement class. A hook usually tells you that something happened,Continue reading “render() and renderedCallback() in LWC”

constructor in Lightning Web Component

Constructor() method fires when a component instance is created. The constructor in LWC flows from parent to child which means Constructor of Parent component will get called first if you have parent child component composition. Child Component and Controller – childComp .html <template> <lightning-card title=“Child Component”> <div class=“slds-p-left_medium slds-align_absolute-center”>                 Child Component Called </div> </lightning-card> </template> childComp.js import { LightningElement } from ‘lwc’; export default class childComp extends LightningElement {     pChildList = [];     constructor() {Continue reading “constructor in Lightning Web Component”

Secure your code using Inherited Sharing

As you are commonly using with sharing or without sharing in apex class, but using without sharing is insecure when you are exposing you data outside and you need to mention false positive statement to pass security review of you code for AppExchange. Designing Apex classes that can run in either with sharing or without sharing mode at runtimeContinue reading “Secure your code using Inherited Sharing”

Understanding Sharing in Apex Class

To enforce sharing rule on an apex class we use key work – with sharing or with out sharing.  And non-sharing-speficied classes – which is sometime really confusing. By default Apex code run on the System Context, which means In System context apex code can access all Objects and fields – object permission, field-level security(FLS),Continue reading “Understanding Sharing in Apex Class”

Hello World ! LWC

Follow this trialhead module – https://trailhead.salesforce.com/content/learn/projects/quick-start-lightning-web-components 2. Install CLI (Command Line Interface). Download from this link – macOS https://sfdc.co/sfdx_cli_osx Windows 32-bit https://sfdc.co/sfdx_cli_win Windows 64-bit https://sfdc.co/sfdx_cli_win64 2. To check CLI install proper, go to VS Code terminal > write sfdx enter You can get the output – Usage: sfdx COMMAND [command-specific-options] Help topics, type “sfdx helpContinue reading “Hello World ! LWC”

Using Lightning Component in Communities

You can use a custom lightning component in your community, you can drag and drop to add the component to you community page in Community Builder To appear in Community Builder, a component must implement the  interface forceCommunity:availableForAllPageTypes <aura:component implements=”forceCommunity:availableForAllPageTypes” access=”global”> <aura:attribute name=”greeting” type=”String” default=”Hello” access=”global” /> <aura:attribute name=”subject” type=”String” default=”World” access=”global” /> {!v.greeting}, {!v.subject}Continue reading “Using Lightning Component in Communities”

Cacheable apex method [Winter-19]

You can mark an Apex method as storable (cacheable) instead of using setStorable() on every JavaScript action that calls the Apex method to centralize your caching notation for a method in the Apex class. This change applies to orgs with Lightning components in Lightning Experience, Salesforce Classic, and all versions of the Salesforce app. MarkingContinue reading “Cacheable apex method [Winter-19]”

Loading a Record using LDS

To load record using LDS is by including force:recordData in your component while specifying the recordId, mode and layoutType or fields attribute. In the force:recordData tag, specify the ID of the record to be loaded, a list of fields, and the attribute to which to assign the loaded record. force:recordData must specify the following. The IDContinue reading “Loading a Record using LDS”

Lightning Data Service(LDS) in Salesforce

Lightning Data Service(LDS) will work as data layer in Lightning. It is like Standard Controller in Visualforce page, providing access to data without querying. Use LDS to load, create, edit or delete a record in your component without Apex code. LDS handles sharing rules and field-level security for you. Without LDS each component make independentContinue reading “Lightning Data Service(LDS) in Salesforce”

Aura.Action Vs aura:registerEvent in Lightning

Instead of an Aura.Action attribute, you could use  to register an onclick event in the child component. You’d have to define the event and create an action in the child’s controller to fire the event. This event-based approach requires a few extra steps but it’s more in line with standard practices for communicating between components. Action has some known limitations:Continue reading “Aura.Action Vs aura:registerEvent in Lightning”