Saturday, 22 March 2025

Salesforce Integration Mastery ticks

 1.Set Timeout on HTTP Callouts – Always set a timeout on HTTP callouts to prevent long-running transactions from consuming resources.


2.Use Named Credentials for OAuth Flows – Store authentication details securely and simplify token refresh handling.


3.Use HttpCalloutMock for Test Classes – Mock callout responses in tests to avoid dependencies on external systems.


4.Handle Platform Event Failures Gracefully – Implement retry logic for platform event subscribers to handle transient errors.

Thursday, 20 March 2025

Some important Flow Events to use when LWC is embedded inside a screen flow

 Some important Flow Events to use when LWC is embedded inside a screen flow.


1.FlowAttributeChangeEvent:


This event is triggered when a component's property changes during the flow execution. It's vital for keeping data in sync and ensuring that components react in real-time to user input or system changes.

syntax:

 const attributeChangeEvent = new FlowAttributeChangeEvent(

 'todos',

 this._todos

 );

 this.dispatchEvent(attributeChangeEvent);



2.FlowNavigationBackEvent :


If your flow includes multiple screens, this event allows users to go back to the previous screen, offering a more fluid and user-friendly experience, especially in complex processes that require review or corrections.


3.FlowNavigationNextEvent:


This event moves the flow forward to the next screen, ensuring smooth navigation between screens without manual intervention.


syntax:

 // check if NEXT is allowed on this screen

 if (this.availableActions.find((action) => action === 'NEXT')) {

 // navigate to the next screen

 const navigateNextEvent = new FlowNavigationNextEvent();

 this.dispatchEvent(navigateNextEvent);

 }



4.FlowNavigationPauseEvent:


Sometimes, you need to pause a flow. Whether it’s waiting for a user decision or external input, this event lets you pause the flow at any point, offering flexibility in how the flow operates.


5.FlowNavigationFinishEvent:


This event signals the end of the flow. Once triggered, it effectively terminates the flow, ensuring the user knows when the process is complete, and no further actions are needed.



Thursday, 13 March 2025

𝗔𝘃𝗼𝗶𝗱 𝗖𝗣𝗨 𝗧𝗶𝗺𝗲 𝗟𝗶𝗺𝗶𝘁𝘀 𝗶𝗻 𝗔𝗽𝗲𝘅

 Ever faced the dreaded "𝗔𝗽𝗲𝘅 𝗖𝗣𝗨 𝘁𝗶𝗺𝗲 𝗹𝗶𝗺𝗶𝘁 𝗲𝘅𝗰𝗲𝗲𝗱𝗲𝗱" error? 

Salesforce enforces a 𝟭𝟬-𝘀𝗲𝗰𝗼𝗻𝗱 𝗖𝗣𝗨 𝘁𝗶𝗺𝗲 𝗹𝗶𝗺𝗶𝘁 𝗽𝗲𝗿 𝘁𝗿𝗮𝗻𝘀𝗮𝗰𝘁𝗶𝗼𝗻, and hitting it can crash your process.


Here are 𝟱 𝗣𝗿𝗼 𝗧𝗶𝗽𝘀 to optimize CPU usage in Apex:


𝟭. 𝗔𝘃𝗼𝗶𝗱 𝗡𝗲𝘀𝘁𝗲𝗱 𝗟𝗼𝗼𝗽𝘀 

Looping inside another loop can skyrocket CPU usage. Instead, use 𝗺𝗮𝗽𝘀 and 𝘀𝗲𝘁𝘀 for efficient lookups.


𝟮. 𝗨𝘀𝗲 𝗖𝗼𝗹𝗹𝗲𝗰𝘁𝗶𝗼𝗻𝘀 𝗘𝗳𝗳𝗶𝗰𝗶𝗲𝗻𝘁𝗹𝘆 

Instead of multiple SOQL queries inside a loop, 𝗾𝘂𝗲𝗿𝘆 𝗼𝗻𝗰𝗲 and process data in bulk using 𝗟𝗶𝘀𝘁𝘀 or 𝗠𝗮𝗽𝘀.


𝟯. 𝗥𝗲𝗱𝘂𝗰𝗲 𝗖𝗼𝗺𝗽𝗹𝗲𝘅 𝗖𝗮𝗹𝗰𝘂𝗹𝗮𝘁𝗶𝗼𝗻𝘀 

Break down complex logic, cache repetitive computations, and use 𝗹𝗮𝘇𝘆 𝗹𝗼𝗮𝗱𝗶𝗻𝗴 where possible.


𝟰. 𝗣𝗿𝗲𝗳𝗲𝗿 𝗔𝘀𝘆𝗻𝗰𝗵𝗿𝗼𝗻𝗼𝘂𝘀 𝗣𝗿𝗼𝗰𝗲𝘀𝘀𝗶𝗻𝗴 

For heavy operations, move logic to 𝗤𝘂𝗲𝘂𝗲𝗮𝗯𝗹𝗲 𝗔𝗽𝗲𝘅, 𝗕𝗮𝘁𝗰𝗵 𝗔𝗽𝗲𝘅, or 𝗣𝗹𝗮𝘁𝗳𝗼𝗿𝗺 𝗘𝘃𝗲𝗻𝘁𝘀 instead of synchronous execution.


𝟱. 𝗠𝗶𝗻𝗶𝗺𝗶𝘇𝗲 𝗥𝗲𝗰𝘂𝗿𝘀𝗶𝘃𝗲 𝗧𝗿𝗶𝗴𝗴𝗲𝗿𝘀 

Use static variables to prevent unwanted recursion and avoid unnecessary trigger executions.


𝗕𝗼𝗻𝘂𝘀 𝗧𝗶𝗽: Use the 𝗟𝗶𝗺𝗶𝘁𝘀.𝗴𝗲𝘁𝗖𝗽𝘂𝗧𝗶𝗺𝗲() method to track CPU usage in real-time and optimize accordingly.

Monday, 3 March 2025

How do you handle Large Data Volumes (LDV) in Salesforce?

 When dealing with millions of records, performance and scalability become crucial. Here are the best practices to efficiently manage Large Data Volumes (LDV) in Salesforce:


1️.Indexes & Skinny Tables – Use standard/custom indexes & skinny tables to optimize queries.

2️.Selective SOQL Queries – Filter records using indexed fields to avoid full table scans.

3️.Asynchronous Processing – Use Batch Apex, Queueable Apex, and Future Methods to handle bulk operations.

4️.Data Archiving – Move old data to Big Objects or external storage to improve performance.

5️.Bulk Data Processing – Utilize Bulk API, Data Loader, or ETL tools for efficient record management.

6️.Avoid Triggers on Bulk Operations – Always bulkify triggers & minimize DML operations inside loops.

7️.Use Composite API – Reduce API callouts by grouping multiple requests into one.

8️.Dividing Data by Ownership – Implement Divisional Sharing, Role Hierarchies, or Territory Management to optimize access control.


🔹 Additional Best Practices:

✅ Use Field History Tracking Efficiently – Track only necessary fields to avoid storage overhead.

✅ Optimize Reports & Dashboards – Apply filters on indexed fields to improve performance.

✅ Leverage External Objects (Salesforce Connect) – Store non-essential data externally & access via External Objects.