Tuesday, 20 February 2024

Important in Salesforce

 CPQ

Vlocity (Omni studio) (Industries cloud)

Financial Service Cloud - 

Field Service Lighting - 

LWC in salesforce

 Differences between Aura and LWC ?

Different ways to call apex from LWC and how each are different from other

Events in LWC

Lighting Data Service and wire ui methods

OWD and FLS in LWC

Different decorators and its uses

LWC lifecycle hook

Uses of async ,await, promise.All, promise.race

use of refershApex

why we need to import in lwc

why we need to extends extends LightningElement 

are we allowed to perform dml in @wire or cacheable=true ---answer is No we will get too many DML exception



==================================================================

Different ways of calling Apex from LWC

imperative means it will not update the changes automatically on UI

reactive means if anything changes in js ,component will be re-render and show updated value on UI

1) @wire - reactive as well imperative (it is automatic ,everything take care by framework)

2) connectedCallback - imperative (called only once when dom is inserted) (call another function which will call apex method -so this is manual)

3) imperative way to call apex method through some action


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Different Decorators in lwc

Track and API and wire


Both @track and @api mark a property as reactive. If the property's value changes, the component rerenders. Tracked properties are private, where properties decorated with @api are public and can be set by another component


@track and @api - use to make property reactive

@track - private with own component

@api - make property public - so that parent component can call child method,parent component can pass value to it's attribute


can we use @api property within component and is it reactive within component?

we can use withing component ,but it is not reactive within component,it is only reactive for parent or container component


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

EVENTS in LWC

passing value from parent to child is same as aura by passing value to properties

passing value from child component to parent component-


a) with in hierarchy (same as component in aura) bubble phase

use custom events - 

this.dispatchEvent(newcustomEvent(eventName, props); EventTarget.dispatchEvent()


 <c-child-cpm eventName={methodName}



b) out of hierarchy (same as application in aura)

i) publish subscribe model

ii) lightning message service (also use to communicate between aura/lwc/vf)

the choice between pub-sub and LMS depends on the specific needs and architecture of your application. It's also worth noting that LMS provides a more standardized and platform-integrated solution, while a custom pub-sub model allows for greater flexibility and customization.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

APEX FROM LWC:

before calling apex class make sure that there is easy way to get data using LDS.

The easiest way to work with Salesforce data is to use base Lightning components built on Lightning Data Service (LDS). If you need more flexibility, use a Lightning Data Service wire adapter directly. Each wire adapter provides different data and metadata. The wire service provisions the data and metadata to your component.

ways to call apex method from lwc :

The lightning/uiGraphQLApi - very much new (Spring 2023) and lightning/ui*Api modules provide the Lightning Data Service (LDS) wire adapters and functions.


ui -api - uiRecordApi  - getRecords,getRecord,createRecord...

uiRelatedListApi,



All wire adapters in the lightning/ui*Api modules respect object CRUD rules, field-level security, and sharing. If a user doesn’t have access to a field, it isn’t included in the response.


1) @wire - cached = true , called after  contructor,connected callback

2) imperative - no cached , called explicitly - like event ,on from other js method


APEX CLASS::

param - Using maps isn’t supported for both imperative and wired Apex calls. 

@AuraEnabled(cacheable=true)



RefreshView API - refresh page data without loading page, working when org has Lighting locker service enable




::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

life cycle hook

1) parent contructor - comp instnasite -> set property

2) p-cmp inserted in dom

3) p-connectedCallback

4) p-rendered in dom

5) chile -contructor

6) c- contructor

6) c- connectedcallback

7) c- renderedcallback

8) p- renderedcallback


1) parent - removed from dom

2) disconnected callback for parent

3) disconnected callback for child


** errorCallback


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;;

async ,await, promise.All, promise.race


async function abc{

await data(); //stop execution until data is completed

const test1 = 'make call';

const test2 = make function call 2

promise.all[test1,test2]; //both test1 and test 2 will run in parallel but it will wait until both are resolved/rejected


promise.race[test1,test2]; //execution resume soon either of them is rejected or resolved





}



::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

OWD and FLS in lwc:


what all ways lwc supports owd

lds ,apex , ui @wire methods , calling lwc component on app builder ,record details all supports owd bydefault


what all ways lwc supports fls

@wire(getRecord) Method:

Lightning Data Service (force:recordData):

Dynamic Data Binding

Apex Controllers with sharing


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;


Lighting Data Service :







::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@wire ui method









Heap Size and Apex CPU Time Limit

  Heap Size - 1) Memory size for holding object , variables and records 2) CPU Time limit -  1) time consuming during whole transaction   ...