Posts

Data Skew in Salesforce

Image
Data skew in Salesforce refers to a condition where the distribution of related records is uneven or imbalanced across parent records. This can occur within standard or custom objects when many records are associated with a single account, user, or parent record.  Two primary types of skew can happen in Salesforce: Ownership Data Skew: This happens when a single user owns many records. For example, suppose one user owns tens of thousands of account or opportunity records. In that case, it can cause performance issues because the system optimizes sharing calculations based on a more balanced record ownership model. Parent-Child Data Skew: This is a situation where a large number of child records are linked to a single parent record. A typical example is having thousands of contact records associated with a single account. When a child record is created, updated, or deleted, Salesforce must lock the parent record to maintain data integrity. This can lead to contention and performa...

How to determine which release my org is running and Salesforce instance’s data centers ?

Image
  Find my Instance -With a globally distributed data center strategy, Salesforce is committed to being the most secure, trusted, and reliable cloud computing service. Use the map to explore and find your Salesforce instance’s data centers. https://availability.salesforce.com/find-my-instance/ Check Salesforce Instance Status - Check service availability and performance for Salesforce products. https://status.salesforce.com/ Where is my Salesforce instance located? -  https://help.salesforce.com/s/articleView?id=000396845&type=1 Find the release version of Salesforce production or sandbox org https://help.salesforce.com/articleView?id=000317969&type=1&mode=1 Find Salesforce Edition and API version https://help.salesforce.com/articleView?id=000334996&type=1&mode=1 https://www.youtube.com/watch?v=jCsK64zIxbc If you like to see it in xml, goto /services/data/ on your instance. https://[instance].salesforce.com/services/data/ https://[domain].lightning.f...

What is Transaction Finalizers ?

Transaction Finalizers in Salesforce Apex are a feature that provides developers with a mechanism to execute logic after a transaction is completed, regardless of whether it's successful or encounters unhandled exceptions. This is particularly useful in the context of Asynchronous Apex, such as future methods, batch jobs, and queueable Apex. You can specify a piece of Apex code to run after the asynchronous operation with transaction finalizers. This flexibility allows you to adapt to various scenarios, benefiting resource cleanup, logging, notifications, or other post-processing operations, giving you a sense of control over your code execution. To use a transaction finalizer, you need to implement the Database. Finalizer interface in your Apex class. The execute method in this interface is invoked after the transaction that the asynchronous code is part of either successfully commits or is rolled back due to an exception Transaction finalizers allow you to attach a post-action s...

Salesforce Platform Event

Image
Platform Events provide a way to deliver secure, scalable, and customizable event notifications within and outside of the Salesforce platform. Platform Events are based on the publish-subscribe model, allowing publishers to broadcast events and subscribers to receive and process those events in real time. Salesforce Event Bus Example: OrderPlaced Platform Event Let's assume you want to create a Platform Event called OrderPlaced__e to represent the event of a new order being placed in your Salesforce org. This event will contain information about the order, such as the order ID, customer name, and total amount. Define the Platform Event Schema: Go to Setup > Platform Events > New Platform Event. Define fields for the event, such as OrderID__c, CustomerName__c, and TotalAmount__c. Publish the Platform Event: You can publish a Platform Event using Apex, Process Builder, Flow, or other methods. Below is an example of publishing an event using Apex. // Publish OrderPlaced event Or...

Getting Started with Apex

Image
What is Apex ?  Apex, a strongly typed, object-oriented programming language, empowers developers to execute flow and transaction control statements on the Salesforce servers in conjunction with calls to the API. It's a proprietary language developed by Salesforce, specifically designed to enable the creation of robust business logic within the Salesforce platform. With its syntactical similarity to Java, Apex serves as the backend code that can manipulate data in Salesforce, execute complex validation rules, and automate intricate business processes. Critical features of Apex include: Integration with Salesforce Data : Apex allows you to write complex queries and transactions against the data stored in Salesforce. Transactional Control: Operations in Apex are transactional, meaning that all DML operations can be rolled back if any error occurs during the transaction process. Governor Limits: Salesforce imposes runtime limits, known as governor limits, to ensure that runaway Apex...

Lightning Components Performance Best Practices

Optimizing the performance of Lightning components is crucial for delivering fast and responsive user experiences in Salesforce applications.  Here are some best practices to improve the performance of Lightning components: Use minified versions of libraries and style sheets Use a content delivery network (CDN) Enable browser caching Use smaller image files CDN and Browser Caching wherever possible is a given.  Cloudflare CDN was used. Akamai is another common option. this is a must-have Custom Fonts (TTF files) were used from Google in the site implementation which was surprisingly taking a long time for browsers to download and use. So we moved to standard fonts which increased the score significantly. If you absolutely need to use Custom Fonts, then there are options in the community to preload this custom font as a static resource which loads faster compared to the Google Reference\ The CSS file was heavily optimized and instead of using images, we used CSS styles for some...

Use of Safe Navigation Operator

Safe Navigation Operator Instead of using explicit, sequential checks for null references, use the safe navigation operator (?.). This new operator short-circuits expressions that attempt to operate on a null value and returns null instead of throwing a NullPointerException. NOTE: All Apex types are implicitly nullable and can hold a null value returned from the operator. Example - Account acc = [SELECT Name FROM Account WHERE Id = :accId]; if (acc != null) {     return acc.Name; } Using Safe Navigation Operator String accName = acc?.acc.Name; String accName =  [SELECT Name FROM Account WHERE Id = :accId]?.Name; The Safe Navigation Operator (?.) in Apex is a feature that allows developers to safely navigate objects and data structures, avoiding null pointer exceptions. When you use the Safe Navigation Operator to access a chain of references, Apex will evaluate the expression from left to right and return null immediately if it encounters a null reference rather tha...