Salesforce Developer

500+ Salesforce Developer Interview Questions and Answers

Updated 24 Jun 2025
search-icon

Asked in Cognizant

1d ago

Q. Write a trigger to update related Opportunity records when an account is updated.

Ans.

Trigger to update Opportunities when an Account is modified in Salesforce.

  • Use 'after update' trigger on Account object to capture changes.

  • Query related Opportunities using 'SELECT Id FROM Opportunity WHERE AccountId = :Trigger.newMap.keySet()'.

  • Update Opportunity fields based on Account changes, e.g., Account Name.

  • Use 'update' DML operation to save changes to Opportunities.

Asked in Deloitte

6d ago

Q. Write a trigger to update a contact when an account's phone number is changed.

Ans.

Trigger to update contact when accounts phone changed

  • Create a trigger on Account object

  • Query for related Contacts

  • Update Contact phone field with Account phone field value

Salesforce Developer Interview Questions and Answers for Freshers

illustration image

Asked in Infosys

6d ago

Q. How do you make the child records read-only if the parent record's field is updated to a specific value?

Ans.

Child records can be made read-only when parent record's field is updated using validation rules.

  • Create a validation rule on child object

  • Use ISCHANGED() function to check if parent field is updated

  • Use PRIORVALUE() function to get the previous value of parent field

  • Use ISBLANK() function to check if the previous value of parent field is blank

  • Use ISNEW() function to allow creation of child records

  • Use OR() function to combine all conditions

  • Throw an error message if all conditions...read more

Asked in Cognizant

3d ago

Q. How many ways can asynchronous code be written in Salesforce?

Ans.

There are multiple ways to write asynchronous code in Salesforce.

  • Using @future annotation

  • Using Queueable interface

  • Using Batch Apex

  • Using Platform Events

  • Using Asynchronous Apex REST Callouts

Are these interview questions helpful?

Asked in TCS

2d ago

Q. Difference between Roles & Profiles, Difference between Workflow-ProcessBuilder-Flow,Types of Workflow and how to set them up,Trigger context variables

Ans.

Explaining the difference between Roles & Profiles, Workflow-ProcessBuilder-Flow, types of Workflow, and Trigger context variables.

  • Roles define the level of access a user has to records in an organization, while profiles define the level of access a user has to objects and fields.

  • Workflow, Process Builder, and Flow are automation tools used to automate business processes in Salesforce.

  • Workflow rules are used to automate standard internal procedures and processes to save time ...read more

Asked in Infosys

6d ago

Q. How do you call a controller method from JavaScript in a Visualforce page?

Ans.

To call a controller method from JavaScript in a Visualforce page, use the actionFunction tag.

  • Create a controller method in the Apex class.

  • Add an actionFunction tag in the Visualforce page.

  • Call the actionFunction from JavaScript using its name.

  • Pass parameters to the controller method using the actionFunction tag.

  • Use the rerender attribute to update the page after the controller method is called.

Salesforce Developer Jobs

Volvo Group logo
Salesforce Developer 5-10 years
Volvo Group
4.1
Bangalore / Bengaluru
TekWissen logo
Salesforce Developer 4-8 years
TekWissen
4.8
Kolkata
CGI Information Systems and Management Consultants logo
Salesforce Developer 8-12 years
CGI Information Systems and Management Consultants
4.0
Bangalore / Bengaluru

Asked in Infosys

1d ago

Q. How do you load both parent and child records at a time using data loader?

Ans.

Use data loader's parent-child functionality to load both parent and child records at once.

  • Create a CSV file with both parent and child records

  • Use the data loader's parent-child functionality to map the relationship between the two

  • Ensure that the parent records are loaded before the child records

  • Use the data loader's insert or upsert operation to load the data

Asked in TCS

2d ago

Q. Batch class and its functions, use of stateful interface in batch class

Ans.

Batch class is used to process large data sets in chunks. Stateful interface maintains state between batches.

  • Batch class implements Database.Batchable interface

  • It has three methods: start(), execute() and finish()

  • Stateful interface is used to maintain state between batches

  • Stateful variables can be declared outside of the execute() method

  • Example: Batch class to update all accounts with a specific field value

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Asked in Infosys

3d ago

Q. What are collection variables and when do we use them in Apex?

Ans.

Collection variables are used to store multiple values of the same data type in Apex.

  • Collection variables include Lists, Sets, and Maps.

  • Lists are ordered collections of elements that can contain duplicates.

  • Sets are unordered collections of unique elements.

  • Maps are collections of key-value pairs.

  • Collection variables are useful for iterating over multiple values and performing operations on them.

  • Example: List<String> names = new List<String>{'John', 'Jane', 'Bob'};

  • Example: Set<...read more

3d ago

Q. How do you remove leading whitespaces from a string in Python?

Ans.

Python provides a built-in method to remove leading whitespaces from a string.

  • Use the lstrip() method to remove leading whitespaces from a string.

  • lstrip() method removes all whitespaces from the beginning of the string.

  • Example: string = ' Hello World' string.lstrip() Output: 'Hello World'

Asked in P2P SYSTEM

2d ago

Q. 1. Write apex trigger on Account Object to update Contact Detail Field . 2. What is Governor Limit in salesforce . 3. What is Relationship in salesforce. 4. What is lookup relationship . 5. What is custom objec...

read more
Ans.

Answers to Salesforce Developer interview questions

  • 1. Use trigger.new to get the updated account records and update the related contact detail field

  • 2. Governor limits are the limits set by Salesforce to ensure efficient use of resources and prevent abuse

  • 3. Relationship in Salesforce refers to the association between two objects

  • 4. Lookup relationship is a type of relationship where one object has a reference to another object

  • 5. Custom object is an object created by the user to...read more

Asked in Accenture

3d ago

Q. Write a batch Apex class to update the account rating.

Ans.

Batch code to update account rating

  • Create a batch class implementing Database.Batchable interface

  • Query for accounts with specific criteria

  • Update the rating field for each account

  • Execute the batch class using Database.executeBatch method

Asked in TCS

1d ago

Q. what is salesforce,governer limits,profiles,roles,visualforce,apex

Ans.

Salesforce is a cloud-based CRM platform. Governor limits are limits on resources. Profiles and roles control access. Visualforce and Apex are development tools.

  • Salesforce is a cloud-based CRM platform used for managing customer data and interactions.

  • Governor limits are limits on resources such as CPU time, database queries, and API calls.

  • Profiles and roles control access to data and functionality within Salesforce.

  • Visualforce is a development tool used for creating custom us...read more

1d ago

Q. What are the types of integration available with Salesforce?

Ans.

Salesforce offers various types of integration options to connect with external systems.

  • SOAP API: Allows integration with external systems using SOAP protocol.

  • REST API: Enables integration with external systems using RESTful web services.

  • Bulk API: Facilitates integration for large data volumes using batch processing.

  • Streaming API: Provides real-time integration by pushing data updates to external systems.

  • Outbound Messaging: Sends notifications to external systems using SOAP o...read more

Asked in Grenud

2d ago

Q. Write a SOQL query to find the Team record where the Player record name is Virat Kohli and the Team name is India, assuming Team is the parent object and Player is the child object.

Ans.

SOQL query to find player 'Virat Kohli' in team 'India' using parent-to-child relationship.

  • SOQL (Salesforce Object Query Language) is used to query Salesforce data.

  • In a parent-to-child relationship, you can query child records using a subquery.

  • The query structure for this scenario would be: SELECT Id, (SELECT Id FROM Players__r WHERE Name = 'Virat Kohli') FROM Team__c WHERE Name = 'India'.

  • Ensure that 'Players__r' is the correct relationship name for the child object in your S...read more

Asked in Infosys

5d ago

Q. Write a trigger that follows best practices. When a new contact is inserted, check if the account has a primary contact. If not, insert the new contact as the primary contact. If a primary contact already exist...

read more
Ans.

Trigger to ensure only one primary contact per account in Salesforce.

  • Use a before insert trigger to check for existing primary contacts.

  • Query the Account object to find if a primary contact exists.

  • If a primary contact is found, add an error to the contact record.

  • Use a Set to track account IDs for efficient lookups.

  • Example: 'if (existingContacts.size() > 0) { contact.addError('Already present'); }'

Q. If a SOQL query in a trigger fetches more than 50,000 records, how would you handle that?

Ans.

To handle more than 50K records fetched by SOQL in trigger, use batch apex or pagination.

  • Use batch apex to process records in smaller chunks

  • Implement pagination to limit the number of records fetched at a time

  • Consider using selective SOQL queries to reduce the number of records fetched

  • Avoid using SOQL queries inside loops

  • Use query optimizer tool to optimize SOQL queries

Asked in Deloitte

5d ago

Q. Describe a scenario where you would create a one-to-one relationship in Salesforce.

Ans.

To create a 1 to 1 relationship in Salesforce, use a lookup field on the child object pointing to the parent object.

  • Create a lookup field on the child object that references the parent object.

  • Ensure that the lookup field has a unique constraint to enforce the 1 to 1 relationship.

  • Use validation rules or triggers to prevent multiple child records from being linked to the same parent record.

6d ago

Q. Write code to create the following pattern: {star pattern}

Ans.

Code to create a star pattern

  • Use nested loops to print the pattern

  • The outer loop controls the number of rows

  • The inner loop controls the number of stars to print in each row

  • Use a combination of spaces and stars to create the pattern

3d ago

Q. How does security work in Apex? For example, if a user does not have access to the Phone field, how does the query SELECT id, Name, Phone from Account WITH_SECURITY_ENFORCED work?

Ans.

In Apex, security is enforced by default. If a user doesn't have access to a field, they won't be able to query it.

  • In Apex, security is enforced by default, meaning that users can only access data they have permission to see.

  • If a user doesn't have access to the Phone field in the Account object, they won't be able to query it even with WITH_SECURITY_ENFORCED.

  • The SELECT id, Name, Phone from Account WITH_SECURITY_ENFORCED query will only return the id and Name fields for users ...read more

3d ago

Q. Describe the standard objects in Salesforce and how you would insert data into them.

Ans.

Standard objects and how to insert data in Salesforce

  • Standard objects are pre-built objects in Salesforce such as Account, Contact, Lead, etc.

  • Data can be inserted into Salesforce using Data Loader, Apex Data Loader, or through API calls

  • Data can also be inserted manually through the Salesforce UI

  • Data can be inserted in bulk or one record at a time

3d ago

Q. Can we use Trigger.new() in before and after triggers?

Ans.

Yes, we can use trigger.new() in before & after trigger.

  • In before trigger, trigger.new() returns the records that are about to be saved.

  • In after trigger, trigger.new() returns the records that have been saved.

  • We can use trigger.new() to access and manipulate the records in the trigger context.

Asked in NTT Data

3d ago

Q. When does APEX CPU Limit Exceeded error happens. What's the best practice to avoid getting this error?

Ans.

APEX CPU Limit Exceeded error happens when code consumes too much CPU time. Best practices include optimizing code, reducing loops, and using asynchronous processing.

  • Avoid using nested loops and optimize code for better performance

  • Use asynchronous processing like @future or Queueable to offload CPU intensive tasks

  • Limit the use of SOQL queries inside loops to reduce CPU consumption

Asked in TCS

4d ago

Q. What is decorator in LWC? Data passing between LWC? Sales and Service Cloud? What is order of execution? Which tool used for deployment? Case management process? about salesforce integration? Flow in Salesforce...

read more
Ans.

Decorators in LWC are used to modify the behavior of a component. Data passing between LWC components can be done using properties and events. Salesforce Sales and Service Cloud are CRM platforms. Order of execution in Salesforce refers to the sequence in which operations are performed. Deployment in Salesforce is done using tools like Salesforce DX. Case management process involves tracking and resolving customer issues. Salesforce integration allows different systems to com...read more

3d ago

Q. What is trigger context?

Ans.

Trigger context refers to the execution context of a trigger in Salesforce.

  • Trigger context provides information about the record(s) that caused the trigger to execute.

  • It includes details like the trigger event type, the old and new versions of the records, and the user who caused the trigger to execute.

  • The trigger context is accessed using the Trigger class in Apex.

  • Example: Trigger context can be used to perform specific actions based on the type of trigger event, such as bef...read more

Asked in NTT Data

1d ago

Q. Write a SOQL query to fetch the values of description field from the Account. Why does "the description field cannot be filtered in the query call"?

Ans.

SOQL query to fetch description field from Account and reason for inability to filter

  • SOQL query: SELECT Description FROM Account

  • Description field is not filterable because it is a long text field

  • Long text fields cannot be filtered in SOQL queries

Q. Write a trigger. There are three objects: A (parent), B (child), and C (grandchild). When the grandchild (C) is updated, update the description of A with the description of C.

Ans.

Write a trigger to update the description field on the parent object when the grandchild object is updated.

  • Create a trigger on the grandchild object

  • Use a SOQL query to retrieve the parent object

  • Update the description field on the parent object with the grandchild's description

3d ago

Q. Write a trigger that, when inserting a contact (application user), checks if the contact is associated with any account. If not, assign it to a 'Test Account'. If the 'Test Account' does not exist, create it, e...

read more
Ans.

Trigger to assign or create a Test Account for Contacts without an associated Account.

  • Use an 'after insert' trigger on the Contact object.

  • Query for existing 'Test Account' to avoid duplicates.

  • If no Account is associated with the Contact, assign the existing 'Test Account'.

  • If no 'Test Account' exists, create one and associate it with the Contact.

  • Ensure to handle bulk inserts to avoid governor limits.

Asked in Capgemini

2d ago

Q. How to invoke flows - using other flows and Apex. How do we invoke an apex class from a flow and pass variables?

Ans.

Flows can be invoked using other flows and Apex. Apex classes can be invoked from a flow by using invocable methods and passing variables as input parameters.

  • To invoke a flow from another flow, use the 'Launch Flow' element in the Flow Designer.

  • To invoke an Apex class from a flow, create an invocable method in the Apex class and annotate it with @InvocableMethod.

  • Pass variables from a flow to an Apex class by defining input parameters in the invocable method.

  • In the flow, use t...read more

Q. Describe a trigger scenario where the count of child records is updated on the parent record using a trigger. How do you bulkify a trigger?

Ans.

Bulkify a trigger to count child records and update parent records efficiently in Salesforce.

  • Use a Map to store parent records and their corresponding child counts.

  • Query all relevant child records in a single SOQL query to avoid governor limits.

  • Iterate through the child records and populate the Map with counts.

  • Update the parent records in bulk after processing all child records.

  • Example: If a parent Account has multiple Contacts, count them and update a custom field on the Acc...read more

1
2
3
4
5
6
7
Next

Interview Experiences of Popular Companies

TCS Logo
3.6
 • 11.1k Interviews
Accenture Logo
3.8
 • 8.6k Interviews
Infosys Logo
3.6
 • 7.9k Interviews
Wipro Logo
3.7
 • 6k Interviews
Cognizant Logo
3.7
 • 5.9k Interviews
View all
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Calculate your in-hand salary

Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary

Salesforce Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits