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?
Aspect | Master-Detail Relationship | Lookup Relationship |
---|---|---|
Nature | Parent-child relationship with cascade behavior | Simple association between two objects |
Ownership | Child record is owned by the parent | Child record is not owned by the parent |
Deletion Behavior | Cascade deletion of child records (dependent) | Child records remain even if parent is deleted |
Required Relationship | Always required on the child side | Optional relationship |
Roll-Up Summary | Can have roll-up summary fields on the parent | Cannot have roll-up summary fields |
Field Creation | Child records remain even if the parent is deleted | Creates a custom field on the child object |
Sharing | Inherits parent’s sharing settings | Inherits parent’s sharing settings (by default) |
Polymorphic | Supports polymorphic relationships (multiple parents) | Does not support polymorphic relationships |
Hierarchical | Can be used to create hierarchical relationships | Cannot be used to create hierarchical 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?
Aspect | Role | Profile |
---|---|---|
Purpose | Defines a user’s position in the hierarchy | Defines what a user can do in Salesforce |
Data Access | Controls data visibility and sharing | Controls object access and permissions |
Hierarchy Control | Determines user’s place in the hierarchy | Does not affect hierarchy structure |
Multiple Assignment | Can have multiple roles | A user can have only one profile |
5. what is the difference between a profile and a permission set?
Aspect | Profile | Permission Set |
---|---|---|
Usage | Assigned to users as part of their user settings | Assigned to users on top of their existing profile |
Object Permissions | Controls object-level access | Provides additional object and field permissions |
Field Permissions | Determines field-level access | Provides additional field-level permissions |
User Permissions | Defines user-level capabilities | Provides additional user-level capabilities |
Tab Visibility | Controls access to tabs and apps | Can extend or modify tab and app visibility |
System Permissions | Grants general system-level privileges | Provides additional system-level privileges |
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?
Aspect | with sharing | without sharing |
---|---|---|
Data Visibility | Enforces record-level and field-level security | Ignores record-level and field-level security |
User Context | Uses the user’s permissions and sharing settings | Runs in system context with full data access |
Impact on Sharing | Adheres to organization-wide defaults and sharing rules | Bypasses organization-wide defaults and sharing rules |
Use Cases | Typically used to enforce data security in business logic | Used when sharing rules and security are not relevant |
Governor Limits | Operates within the constraints of user permissions | Subject to governor limits without user context |
Collaboration | Suitable for scenarios where data should be protected based on user access | Suitable for administrative tasks and data operations |
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?
Aspect | Custom Settings | Custom Metadata Types |
---|---|---|
Purpose | Store configuration data or application settings that can be accessed across the organization. | Store configuration data or application settings that can be accessed across the organization. |
Data Storage | Stored in Salesforce as records (sObjects) with API limits for data retrieval. | Stored in Salesforce as records (sObjects) with no API limits for data retrieval. |
Visibility Scope | Hierarchical (org-wide, profile, user) or org-wide only. | Org-wide. Custom metadata records can be accessed by all users. |
Schema Type | Each custom setting has its own schema defined in Salesforce. | Defined using custom metadata type definition. |
Configuration Changes | Can be changed via the UI or programmatically (Apex). | Can only be changed via API (Apex, API, or Metadata API). |
Deployment | Can be migrated between environments using Change Sets, Packages, or Metadata API. | Can be included in Change Sets, Metadata API, and other metadata deployment tools. |
Protection | Can be protected to prevent unauthorized changes. | Can be protected using managed packages for controlled changes. |
Record Relationships | Custom settings cannot have direct relationships with other objects. | Custom metadata records can have lookup relationships to other custom metadata types. |
Apex Triggers and Workflow | Custom settings can be accessed and modified using Apex triggers and workflow rules. | Custom metadata can be accessed and modified using Apex triggers, but only through Apex code. |
Use Cases | Common for storing configuration settings, feature toggles, and app preferences. | Common for storing configuration settings, feature configurations, and app 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?
Aspect | render Attribute | rendered Attribute |
---|---|---|
Purpose | Specifies whether a component should be displayed | Specifies whether a component should be rendered |
Attribute Type | Boolean | Boolean or Expression (True/False) |
Expression Support | Supports dynamic binding using controller variables | Supports dynamic binding using controller variables or formula expressions |
Conditional Display | Uses the value provided to determine visibility | Uses a condition to determine rendering |
Interaction with CSS | Directly controls the rendering of the component | Conditional rendering can affect CSS rules |
Interaction with JS | The component’s existence depends on condition | The component’s existence depends on the condition |
Apex Access | Can be used directly within Visualforce markup | Can be used directly within Visualforce markup |
Example | <apex:outputText value="Hello" render="{!showText}" /> | <apex:outputText value="Hello" rendered="{!showText}" /> |
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:
Trigger.isBefore
: This Boolean context variable istrue
if the trigger is executing in the “before” context, meaning before the records are saved to the database.Trigger.isAfter
: This Boolean context variable istrue
if the trigger is executing in the “after” context, meaning after the records are saved to the database.Trigger.isInsert
: This Boolean context variable istrue
if the trigger is executing due to an insert operation.Trigger.isUpdate
: This Boolean context variable istrue
if the trigger is executing due to an update operation.Trigger.isDelete
: This Boolean context variable istrue
if the trigger is executing due to a delete operation.Trigger.isUndelete
: This Boolean context variable istrue
if the trigger is executing due to an undelete operation (recovering a deleted record).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.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.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.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.Trigger.size
: This context variable holds the total number of records in the trigger context. It’s a count of the records inTrigger.new
orTrigger.newMap
.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?
Aspect | Cross-Object Formula Field | Roll-Up Summary Field |
---|---|---|
Purpose | Display calculated data on a record and child objects | Display aggregated data on a parent and child objects |
Calculation Type | Calculations on related object fields | Aggregations (SUM, COUNT, AVG, etc.) |
Data Display Location | On the record being viewed | On the parent record |
Related Object Relationship | Requires a master detail or lookup | Requires a master detail or lookup and child objects |
Supported Operations | Supports various operations such as arithmetic, concatenation, etc. | Supports aggregations like SUM,COUNT, AVG, MIN, MAX, etc. |
Example Use Case | Display Account Industry on an Invoice record | Display total Opportunity amounts on an Account record |
30. is it possible to invoke one controller method from another in 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, Twitter, Trailhead. So you won’t miss out on all future articles.