Major Topics to Cover Before Attending Any Salesforce Interview
Preparing for a Salesforce interview requires a comprehensive understanding of various topics, especially those related to API integration, Experience Cloud, and handling common exceptions. Here’s a guide to help you navigate these crucial areas and ace your interview.
API Integration Related Topics
Platform Events and Their Uses
Platform Events are a powerful feature in Salesforce that enable real-time integration between systems based on event-driven architecture. One notable use case is ‘Change Data Capture (CDC)’, which captures changes to Salesforce records and publishes them as platform events. ReplayId in events also play important role.
This is crucial for keeping external systems in sync with Salesforce data.
Generally in Salesforce Interview these questions are also often asked like what are Named Credentials, Remote Site Settings, which authentication method is generally used (like Oauth 2.0) etc.
Mixed DML Errors
Understanding Mixed DML Errors
Mixed DML errors occur when you attempt to perform DML operations on both setup and non-setup objects within the same transaction. Setup objects include configuration and metadata objects, while non-setup objects are standard and custom objects.
Identifying Non-Setup Objects
Non-setup objects are generally user-created or standard objects like Account and Contact. Setup objects include entities such as User, Profile, and Organization.
Resolving Mixed DML Errors
To resolve Mixed DML errors, you should separate the DML operations into different transactions using asynchronous methods like future methods or Queueable Apex. This helps avoid the conflict between setup and non-setup objects.
Experience Cloud Questions
User Roles in Experience Cloud
In Experience Cloud, you can create multiple user roles to define different levels of access and permissions for community users. The exact number of roles you can create may vary based on your Salesforce edition and licensing.
Difference Between LWR and AURA Sites
– Lightning Web Runtime (LWR): A framework designed for building high-performance web applications using Lightning Web Components.
– AURA Sites: Built using the Aura framework, the predecessor to Lightning Web Components, offering a robust component-based UI framework.
Difference Between Errors and Exceptions
– Errors: Indicate serious problems that a reasonable application should not try to catch, often related to system failures.
– Exceptions: Conditions that an application might want to catch and handle, such as logical errors or invalid user inputs.
Common Exceptions in Salesforce
NullPointerException
Occurs when attempting to access an object that has not been initialized. Ensure all objects are properly instantiated before use.
CPU Time Limit Exception
Triggered when the CPU time allocated(10 seconds) for an Apex transaction is exceeded. Optimize your code to avoid long-running loops and recursive calls.
DmlException
Thrown when a DML operation fails, such as inserting a record that violates a validation rule. Always handle DML operations in try-catch blocks.
FieldIntegrityException
Occurs when data does not adhere to field-level integrity constraints. Ensure data consistency and validation before performing DML operations.
Asynchronous Processes
Future Methods
– Limitations: Cannot pass sObjects as parameters.
– Use Case: Perform operations that can be executed asynchronously, such as callouts to external services.
Queueable Apex
– Limitations: Transaction Finalizers can be used to perform actions once the job is completed.
– Use Case: Chaining jobs and handling large data volumes.
Schedulable Apex
– Mandatory Method: ‘execute’ method.
– Use Case: Schedule Apex to run at specific times.
Batch Apex
– Callouts: Yes, callouts can be performed in Batch Apex using Allow.CallOuts interface.
– Stateful: Use ‘Database.Stateful’ to maintain state across batch transactions.
LWC (Lightning Web Components) Essentials
Constructor
– Purpose: Initialises the component.
– Keyword: ‘super()’ is used to call the parent class constructor.
– Limitations: Avoid heavy computations in the constructor.
LWC Lifecycle Hooks
– constructor: Initialises the component.
– connectedCallback: this hook/method is called when component is inserted into the DOM.
– disconnectedCallback: this hook/method is called when component is removed from the DOM and is a good options for cleanup tasks.
– renderedCallback: Called after every render of the component, flowing from child to parent.
– errorCallback: Called when an error is thrown during the component’s lifecycle.
Difference Between Constructor, ConnectedCallback, and Wire Methods in LWC
– Constructor: Used for initialising the component.
– ConnectedCallback: Used for logic that needs to run when the component is inserted into the DOM.
– Wire Methods: Used for connecting a component to Salesforce data.
Async in JavaScript
Promises
Similar to async processes in Apex, JavaScript uses ‘Promises’ for handling asynchronous operations.
– Utility: Promises allow you to handle asynchronous tasks efficiently.
– Limitations: Promises can be complex to manage when dealing with multiple asynchronous operations.
– .then() Method
When a promise returns two values (either `resolve` or `reject`), the `.then()` method is used to handle the promise response. The result stores the success response, and catch handles any errors.
Apex Sharing Model
This is an important topic of any Salesforce Interview :
Sharing Keywords
– With Sharing: Enforces sharing rules for the current user.
– Without Sharing: Bypasses sharing rules.
– Inherited Sharing: Inherits the sharing settings from the caller.
Impact on Apex Classes
– Explicit Declaration: When you explicitly declare an Apex class as ‘without sharing’, it ignores all sharing rules. Omitting the declaration defaults to `without sharing` if the class is called from another `without sharing` class; otherwise, it follows the default sharing rules.
Mastering these topics will ensure you are well-prepared for your Salesforce Interview. Focus on the practical applications and limitations of each concept, as interviewers often test your understanding through real-world scenarios. Always make sure to go through the new enhancements added by the salesforce which they mention in their spring and summer document releases. For more information on these you can visit the salesforce official documentation as well : https://developer.salesforce.com/docs
Please go through this article to learn about LDS in LWC by clicking here.
FAQs
What are the most important lifecycle hooks in LWC?
The most important lifecycle hooks in LWC are ‘connectedCallback’, ‘disconnectedCallback’, ‘renderedCallback’, and ‘errorCallback’.
How can you debug lifecycle hooks in LWC?
You can debug lifecycle hooks by using ‘console.log’ statements, browser developer tools, and Salesforce’s debugging tools like the Lightning Inspector.
What are common mistakes to avoid in Salesforce Interview with lifecycle hooks?
Common mistakes include performing heavy operations in ‘renderedCallback’, not cleaning up event listeners in ‘disconnectedCallback’, and mismanaging state updates leading to unnecessary re-renders.
How do lifecycle hooks in LWC compare to those in other frameworks?
LWC lifecycle hooks are similar to those in other frameworks like React and Angular, providing methods to manage component creation, updating, and destruction phases.