Salesforce Interview Question — Part 5

Aman Garg
8 min readAug 28, 2023

--

1. What is an Object?

Ans. An object in Salesforce is a fundamental data structure used to store and manage data. Objects can represent various types of entities such as standard objects (like Accounts, Contacts, Opportunities) or custom objects (created by users to suit their specific needs). Objects contain fields to store data and can also have related records through relationships.

2. What is the difference between master details and lookup relationships?

3. What is the junction object?

A junction object is a custom object in Salesforce used to create a many-to-many relationship between two objects. It contains two master-detail relationships (or lookup relationships) to the objects you want to relate. Junction objects are typically used to model complex relationships that can’t be represented directly by a single relationship.

4. What is the difference between role and profile?

5. What is the difference between a profile and a permission set?

6. What is the sharing rule?

Ans. A sharing rule is used to extend access to records that the organization-wide default sharing settings might restrict. It’s a way to selectively share records with specific users or groups based on predefined criteria.

7. What is the difference between With sharing and without sharing?

8. What is the wrapper class?

Ans. A wrapper class is a custom Apex class that is used to hold and manage multiple related data elements from different sources. It’s commonly used to bundle data from multiple objects or query results and pass them to Visualforce pages or Lightning components.

9. what is the batch?

Ans. A batch class in Salesforce is used to process a large number of records in smaller, manageable chunks (or batches). It’s particularly useful when you need to perform operations on a large number of records that might exceed governor limits.

10. can we call batch class from the batch class?

Ans. Yes, you can call one batch class from another batch class. This can be useful for chaining batch jobs to execute in a specific order.

11. What is the way to call batch class?

Ans. You call a batch class by creating an instance of the batch class and then invoking the Database.executeBatch() method, passing in the instance as a parameter.

12. What is the validation rule?

Ans. A validation rule is a business logic rule that you define to enforce certain data entry standards or consistency. It prevents users from entering data that doesn’t meet the specified criteria.

13. What is the record type?

Ans. A record type is a way to categorize and distinguish different types of records within an object. Each record type can have its own set of page layouts, picklist values, and business processes.

14. What is the difference between custom settings and custom metadata?

15. What is the use of wire in LWC?

Ans. The wire is a JavaScript decorator used in Lightning Web Components (LWC) to get data from an Apex method or a wire adapter. It helps you retrieve and refresh data in a reactive manner, automatically handling data updates when they occur.

16. What are the different types of controllers on the vf page?

Ans. In Visualforce pages, you can use three types of controllers:

  • Standard Controller: Represents a standard object, like an Account or Contact.
  • Custom Controller: A user-defined Apex class that extends the ApexPages.StandardController class.
  • Extension Controller: A user-defined Apex class that extends or enhances the functionality of a standard or custom controller.

17. What is the difference between render and rendered in vf page?

18. What are the benefits of using vf pages?

Ans. Visualforce pages in Salesforce offer benefits such as custom user interfaces, integration with data, control over data presentation, and the ability to incorporate business logic.

19. How can we call the parent component to the child component?

Ans. Communication from a child component to a parent component in Lightning Web Components can be achieved by using events.

20. How can we pass the data from the parent to a child component?

Ans. Data is passed from a parent component to a child component in LWC through component properties (attributes).

21. What are the context variables in trigger in Salesforce?

Ans. These context variables help you determine various aspects of the trigger execution, such as the type of trigger event, the records being processed, and more. Here are some commonly used context variables in Salesforce triggers:

  1. Trigger.isBefore: This Boolean context variable is true if the trigger is executing in the "before" context, meaning before the records are saved to the database.
  2. Trigger.isAfter: This Boolean context variable is true if the trigger is executing in the "after" context, meaning after the records are saved to the database.
  3. Trigger.isInsert: This Boolean context variable is true if the trigger is executing due to an insert operation.
  4. Trigger.isUpdate: This Boolean context variable is true if the trigger is executing due to an update operation.
  5. Trigger.isDelete: This Boolean context variable is true if the trigger is executing due to a delete operation.
  6. Trigger.isUndelete: This Boolean context variable is true if the trigger is executing due to an undelete operation (recovering a deleted record).
  7. Trigger.new: This context variable holds a list of the new versions of the records being processed in the trigger. In an update trigger, this holds the updated values.
  8. Trigger.newMap: This context variable holds a map of the new versions of the records being processed, where the keys are record IDs and the values are the record objects.
  9. Trigger.old: This context variable holds a list of the old versions of the records being processed in the trigger. In an update trigger, this holds the values before the update.
  10. Trigger.oldMap: This context variable holds a map of the old versions of the records being processed, where the keys are record IDs and the values are the old record objects.
  11. Trigger.size: This context variable holds the total number of records in the trigger context. It's a count of the records in Trigger.new or Trigger.newMap.
  12. Trigger.operationType: This context variable provides the type of operation that caused the trigger to fire. It can have values like 'INSERT', 'UPDATE', 'DELETE', 'UNDELETE', etc.

22. Why we use Test.StartTest() and Test.StopTest()?

Ans. In Salesforce, Test.StartTest() and Test.StopTest() are methods used in unit tests. They are used to define a block of code that is separate from the rest of the test context. The key purpose of these methods is to reset governor limits. Salesforce enforces certain limits on DML operations, SOQL queries, and more. Wrapping code between Test.StartTest() and Test.StopTest() allows you to reset the limits specifically for that block of code, enabling you to test the impact of your logic without being constrained by the governor limits.

23. What is the purpose of @future Annotation?

Ans. The @future annotation is used in Salesforce Apex to indicate that a method should be executed asynchronously in the background. It allows you to offload long-running or potentially resource-intensive operations to avoid impacting the immediate user experience. Methods annotated with @future are processed in a separate context and have their own governor limits.

24. What is the mixed DML error?

Ans. The “Mixed DML Operation” error occurs in Salesforce when you try to perform a transaction that involves a mix of both setup (metadata) objects and non-setup (standard/custom) objects in a single context. This usually happens when you perform DML operations on both types of objects within the same transaction, and Salesforce enforces a restriction to prevent certain types of mixed operations due to potential security concerns.

25. How can resolve the mixed dml error?

Ans. To resolve the mixed DML error, you need to ensure that DML operations on setup objects and non-setup objects are separated into different transactions. Here are a few approaches:

  • Use Future Methods or Queueable Jobs: You can use @future annotated methods or Queueable Apex to move the DML operations on setup objects to a separate asynchronous context.
  • Use Asynchronous Apex: If possible, move one set of DML operations to an asynchronous context using methods like Queueable or Batch Apex.

26. Write a Query to get all the accounts records that have at least one contact record.

SELECT Id, Name
FROM Account
WHERE Id IN (SELECT AccountId FROM Contact)

27. What is the Cross-object formula field?

Ans. A Cross-Object Formula Field is a calculated field in Salesforce that allows you to reference and perform calculations on fields from related (parent or child) objects. It enables you to display data from related records without having to create custom code. This is particularly useful when you want to display information from a related object on a record’s detail page.

For example, you might have a custom object called “Invoice” and another standard object called “Account.” You could create a Cross-Object Formula Field on the Invoice object that references fields from the related Account object, such as the Account’s Industry field. This way, each Invoice record could display the Industry of its associated Account.

28. What is the SOQL Query?

Ans. SOQL stands for “Salesforce Object Query Language.” It’s a query language used to search your organization’s Salesforce data for specific information. SOQL is similar to SQL (Structured Query Language), but it’s designed specifically for querying Salesforce objects and their relationships.

SOQL queries allow you to retrieve records based on conditions, perform aggregate functions (like SUM, COUNT, etc.), and navigate through object relationships. You can use SOQL in various contexts, including Apex code, Visualforce pages, and API calls.

29. What is the difference between the cross-object formula field and the roll-up summary field?

30. Is it possible to invoke one controller method from another in the aura component?

Ans. Yes, you can definitely invoke one controller method from another in a Salesforce Lightning Aura Component. Aura Components are part of the Salesforce Lightning Framework, which allows you to build dynamic web applications for Salesforce.

In Aura Components, you can call a controller method from another method within the same controller, as long as they are part of the same Aura Component. This is a common practice to organize your component’s logic and improve code reuse.

Here’s a simple example in Aura Component:

({
doMethodA: function(component, event, helper) {
console.log('Executing Method A');
helper.doMethodB(component); // Invoking helper method from another helper method
}
})

Conclusion:

I hope you like this blog and if you want any help let me know in the comment section.

Stay tuned, there is way more to come! Follow me on LinkedIn, Instagram, and Twitter. So you won’t miss out on all future articles.

Originally published at https://amansfdc.com.

--

--

Aman Garg
Aman Garg

Written by Aman Garg

Sr. Executive - Training || 6x Salesforce Certified || 2x Copado Certified || Salesforce Mentor || Founder of Salesforce Learners

No responses yet