Every Salesforce employee needs the latest Salesforce interview questions to crack the interviews. The main reason is Salesforce has become one of the top booming technologies in IT industries. It is the best CRM product in the market today. Because of this reason, IT companies like TCS, Wipro, Accenture, Capgemini, Mindtree, Delloite, PwC etc are hiring a lot of employees working in this technology. Employees are getting great salaries for this niche skill.

As the competitions are high, you must enhance your Salesforce skills. You should be aware of all the important interview questions asked in the hiring. I have taken project-specific interviews for candidates in Salesforce and I have a clear idea of what is asked and what we expect from an employee.  Here are the top Salesforce interview questions asked in any MNCs which you must know.

CRM and Salesforce Basics   

Salesforce Interview Questions

1.  What is CRM?

Ans. : Customer Relationship Management (CRM) is a technology that helps a company to manage the relationships and build progressive interactions with customers. CRM provides tools, strategies to manage customer data, improve business by analytics, reporting, forecasting, etc.

2.  Mention other CRM software apart from Salesforce.

Ans.  These are the other top CRM software solutions apart from Salesforce.

  • HubSpot CRM.
  • Freshsales.
  • Pipedrive.
  • Zoho CRM.

3.  What is Salesforce?

Ans: Salesforce is a Customer Relationship Management (CRM) solution that provides software, platform, infrastructure and manages the relationship between customer and company.

Salesforce acts as:

SaaS: Software as a service salesforce provides software for sales, marketing, call center on demand anytime, anywhere across the globe from any system having.

PaaS: Platform as a service Salesforce provides force.com and Lightning platform to develop and customize the application for business as per the requirement.

4.  What is the advantage of using Salesforce?

 Ans: With the digital age, the way business is also changing. Salesforce provides a cloud-based business application that helps to boost business and build a strong relationship between customer and company. Salesforce is the no. #1 CRM platform and it provides solutions for Sales, Marketing, Service, Community, AI, and whatnot.

  • Sales Cloud gives you all the information to close a deal, manage contacts and opportunities, etc.
  • Service cloud help to provide the best service experience to the customers fast and effectively
  • Marketing Cloud gives a great advantage to get information about leads and generate sales.
  • Community cloud provides a platform for clients, potential customers and employees to help themselves and each other.

And now with the introduction of Artificial intelligence, there are endless possibilities.

5.  What is Org in Salesforce?

Ans:  You can imagine org as an instance of the application which is visible to the customer with all the critical data highly configured and customized with custom fields, workflow, approval process, triggers and, pages and Apex coding.

6.  What is Production?

Ans: Production is the final product that is shared with the customer. Production org contains all the real-time data used for business along with the active users.

7.  What is Sandbox?

Ans:  Sandboxes are the replica of Production org. Multiple copies of Production org are created for different purposed like coding, testing, learning. Sandbox’s storage capacity also depends on the version of the sandbox.

8. What are the different types of Sandbox?

Ans.   There are 4 types of Sandbox:

  • Developer Sandbox
  • Developer pro sandbox
  • Partial data sandbox
  • Full copy sandbox

9. What is the difference between the versions of sandboxes?


Sandbox Developer Developer Pro Partial Full copy
Refresh interval 1 day 1 day 5 days 29 days
data storage 200 MB 1 GB 5 GB same as prod
real-time data does not copy NO limit 5GB same as Prod

Salesforce Configuration

Salesforce interview questions will always consist of the configuration so you much be confident in the basics. You can miss one or two questions in the customization but if you are not able to answer any configuration related questions, you will not be selected.

Salesforce Interview Questions

10. Explain objects Fields and records in Salesforce?

Ans.  An object is similar to a database table.  Let’s say there is a database named Car, in the database we have attributes like color, price, model, brand etc and each attribute has a value. For example:

Color: Black; Price: 4 crore; Model: Aventador; Brand: Lamborghini

If we make this database in Salesforce:

  • Object is the database –> Car
  • Fields are the attributes –> Color, Price, Model, Brand
  • Records are the instances –> Black, 4Crore, Aventador, Lamborghini

11. What are standard and custom objects and how to distinguish between the two?

Ans: Salesforce provides several OOTB (out of the box) objects like Account, opportunity, Campaign, Contact. These are called standard objects.

Based on the business requirement we can create some objects which are not present by default. Those objects are called custom objects.

Difference:  API name of a custom object always ends with __c. example Student__c, Teacher__c etc.

12. What are standard and custom fields and how to distinguish between the two?

Ans. Each standard Object and custom object has certain fields created by default by Salesforce. These fields are called Standard Fields. Example: Name, CreatedBy, LastModifiedBy, Amount.

Fields created by Salesforce Admin based on the business requirements are called custom Fields. These custom fields have __c appended at the end of their API names.

13.  What is OOTB or Out of the box functionality?

Ans. OOTB or Out of the box functionality is all such features that are provided default by Salesforce and can be used just by point and click and there is no need the need of coding. Example standard objects, report and dashboard, standard page layouts, etc.

 14. Why Salesforce is called a Multi-tenant Architecture?

Multi-Tenancy in Salesforce

Ans. Salesforce is called a multitenant Architecture because the same instance is shared with every user. Here every customer is termed as a tenant. And to make sure no particular user exploits the resources Salesforce implements governor limits on the runtime engine. For example: the Total number of SOQL queries issued is 100. The total number of records retrieved by any SOQL query is 50,000 etc.

For more details, you can refer to Apex governor limits

15. What is OWD  or Organization-wide Default?

Ans. Organization-wide Default decided what permission and visibility user has to the records which they do not own. As you can see below screenshot there are options Private, Public Read Only, Public Read/Write and Public Read/ Write/ Transfer.

Note: Public Read/Write/Transfer is available only to lead and case object.

Private:  User cannot see the records which they do not own.

Public Read Only: User can read the records but they cannot edit or transfer the records which they don’t own.

Public Read/Write: Users can read, edit and delete the records but cannot transfer which they don’t own.

Public Read/Write/Transfer: User can read, edit and transfer the ownership of the records which they do not own.

Salesforce interview questions

16. What is Grant Access using hierarchy?

Ans. Grant Access using hierarchy decides if the user in a higher role can see records his subordinates or not. Grant access using hierarchy is enabled for all standard objects by default and can only be changed for the custom objects.

17. How does a salesforce 15 digit ID defer from the 18 digit ID?

Ans. 15 digits case-sensitive version which is referenced in the UI whereas
18 digit case-insensitive version referenced by the APIs.
The last 3 digits of the 18 digit ID are basically a checksum of the capitalizations of the first 15 characters, These 18 digit IDs were created to get compatible with the legacy systems

18.  What is validation rule?

Ans.  The validation rule is used to make sure the user enters the correct value in the field. If the values entered for the field are not appropriate an error message appears either on top of the page or below the specific field.

Validation rules has either a formula or an expression that evaluates to “True” or “False” to validate the values entered.

19.  What is the order of execution which Salesforce follows?

  1. System validation rules
  2. Before triggers are executed
  3. Custom Validation Rules
  4. After triggers
  5. Assignment rules
  6. Auto-response rules
  7. Workflow rules are executed
  8. If the workflow updates any field, before and after triggers are executed one more time
  9. Escalation rules
  10. Executes Criteria Based Sharing rules
  11.  Post-commit logic like sending the email.

Did you know we have an order of execution in the Visualforce page as well? You must read the Order of Execution blog for complete details.

20. What are the Apex code best practices?

  1. Ans.  Bulkify the code.
  2. Avoid SOQL and DML statements within for loops
  3. Use of collections like List, Sets, Maps.
  4. Use Asynchronous apex appropriately.
  5. Write test class for code coverage
  6. Avoid Hard coding IDs (causes issue  while deployment)
  7. Do not use multiple triggers on the same object – Merge them into a single trigger.

 21. What are the different ways to share records in Salesforce? 


  1. Profile/Permission sets
  2. Organization wide defaults (OWD)
  3. Record Ownership
  4. Role hierarchy
  5. Sharing Rules
  6. Criteria based Sharing Rules
  7. Manual Sharing
  8. Apex Sharing

22. Point out the key factors of Salesforce security model.

  • Object-level-Security
    • Profiles
    • Permission sets
  • Field Level Security
  • Record Level Security
    • OWD or Organization wide default
    • Role Hierarchy
    • Sharing Rules
    • Manual Sharing
    • Apex Sharing

Object Relationships

Salesforce Interview Questions

23. List out the different types of Relationships in Salesforce?


  1. Master Detail Relationship
  2. Many-to-Many Relationship
  3. Lookup Relationship
  4. Hierarchical Relationship

24. What is a master Detail relationship and how it differs from the Lookup relationship?


Master detail relationship are called strongly coupled relationship because if the master record will be deleted the detail record also gets deleted however If the detail record is deleted master records remain intact. Each custom object can have at max 2 master detail relationships.

Lookup relationships are called loosely coupled relationship because if the parent record is deleted child record remains undeleted. Each object can have at max 25 lookup relationships.

25. Can a master detail relationship be converted into lookup relationship?

Ans. Yes a master detail relationship can be converted into lookup relationship if the rollup summary field is removed.

Can a Lookup relationship be converted into Master-detail relationship?

Ans. Yes you can convert a lookup to master detail but first you will need to populate the value of each child records.

26. What is a junction object?

Ans. Junction objects are created when an object has in master detail relationship with two parent objects. Junction object are used to create many-to-many relationship between objects.

Note: 1. if we undelete a deleted junction object then the master detail relationship gets converted into lookup relationship.

  1. If any one of the parent record of the junction object gets deleted then the record for the junction object will also get deleted.

27. How many-to –many relationships are created?

Ans. Many-to-many relationships are created by using junction objects. An object will need to be connected to two parent objects in master-detail relationship. This kind of relationship is basically used to link one object to multiple records from other object and vice-versa.


28. What is a self-relationship?

Ans. Self relationship is a kind of lookup relationship where the relation is created on the same object. It means the parent and child objects are same. There is a special category of self-relationship created on user object which is also called hierarchical relationship.

User, Profile, permission Sets, Role

Salesforce Interview Questions

29. What is the difference between Profile and Role?

Ans.  Profiles determine the user has access to which all objects and what kind of permission is available on each object. It also decides which tabs or Apps are visible to the user.  Profiles also regulate system settings such as session settings, login hours, IP range, etc.

Role comes into play when the OWD is set as more restrictive than Public Read/Write. Role hierarchy helps to share records in Hierarchical order. A user in the above role hierarchy can see the records owned by their subordinates. There are 3 options available when a new role is created.

  1. No access:  User in the above role hierarchy will not be able to see the records of their subordinates.
  2. View Only: User in the above role hierarchy will be able to see the records but not edit it.
  3. View and Edit: User in the above hierarchy will be able to view and edit the records.

Profiles provide object level visibility but Roles provide record level visibility.

A user is Salesforce can be created without giving any role but he must have a profile assigned.

30. Can we delete a user in Salesforce?

Ans. We can deactivate a user in Salesforce but cannot delete it.

31. What is permission set?

Ans  To extend the access of a user over profile permission sets are used. Permission sets are collection of settings which is given to user. Suppose there is a profile P assigned to two users U1 and U2.  U2 needs some extra access and permissions to objects. So in this case we can create a permission set and assign it only to U2 without changing anything  in profile and hampering the settings for U1.

A user can have only one profile but he can have multiple permission sets.

Workflows and Approval Processes 

Salesforce Interview Questions

32. What is Workflow?

Ans.  Workflow rule is a business engine which is used to perform certain action depending on the criteria. Workflow rules are fired when a record is either created or edited.

The action which are performed through workflow rules are categorized as:

Immediate Action:  These actions are executed immediately when a record is created or updated.

Time Triggered Action: These actions are executed after a certain time period.

33. What are the different evaluation criteria when creating a workflow rule?

This is one of most asked Salesforce interview questions.

Ans. There are basically 3 evaluation criteria when creating a workflow:

  1. Created :
  2. Created and every time it’s edited
  3. Created and any time it’s edited to subsequently meet criteria
  • Created:  Workflow rule is evaluated only when the record gets created. Logically we can say that this rule never runs more than once per record.
  • Created and every time it’s edited: Workflow rule is evaluated when record is created and every time it is edited. Rule will run repetitively as long as the record is getting updated and criteria meet.

With this option select you cannot add a time-dependent action to the trigger.

  • Created and any time it’s edited to subsequently meet criteria: Rule runs when a record gets created and the criteria meets and for an updated record, rule runs when the record value changes from not meeting the criteria to rule meeting criteria

34. Explain the difference between created and Every time it’s edited and created and any time edited to subsequently meet the criteria.

Ans. Suppose we have created the following workflow:

  • Object : Opportunity,
  • Condition : If Amount > 20,000
  • Action: Update Stage = Closed won.

Created and every time it’s edited

Case:  Amount entered is 30,000 so workflow will be fired and Stage will be updated to Closed Won.

Now, if the amount entered is 50,000 the workflow will fire again trying to update the stage to closed won.

Created and any time it’s edited to subsequently meet criteria
Let’s consider the same workflow mentioned above.

Case: Amount entered is 30,000 so workflow will be fired and Stage will be updated to Closed Won.

Now, if the amount entered is 70,000 the workflow will not run again because in the previous run only workflow met the criteria and we know this rule runs only if the value changes from not meeting the criteria to meeting the criteria.

35. What are the different kinds of workflow actions?


  • Email Alert: Email alerts actions are used to send emails, using email templates to the recipients. Workflow alerts can be sent to any user or contact having a valid email address.
  • Field Update: A field update action updates a field with the value when workflow is fired.
  • Outbound Message: An outbound message action sends information to an endpoint. Outbound messages are configured from Setup
  • Task: Task provides details of an assignment given to a specified user.

36.  What is recursive workflow rule and how can we avoid it?


If we enable the “Re-evaluate Workflow Rules after Field Change” checkbox in the Field Update of a workflow rule and once the field is updated another work if fired which is also having the same checkbox checked recursive workflow loop could happen.

We can avoid recursive workflow by either:

  • Using created, and any time it’s edited to subsequently meet criteria
  • Not enabling  “Re-evaluate Workflow Rules after Field Change” 

37. There is a time based workflow which will update one field after 1 day if the conditions are met. User submits the record and the workflow is in queue. If the user modified the workflow now and change the record so that It does not meet the criteria will field be updated or not at the scheduled time?

Ans. No it will not update the field because the value of the field is now not matching the criteria. 

38. Consider a scenario where we have two workflow rules WF1 and WF2 on Account object. If WF1 fires and if updates a field and now the criteria for WF2 is matched. Will the workflow WF2 fire or not?

Ans. No it will not fire, but to make it happen enable the Re-evaluate Workflow Rules after Field Change checkbox on WF1.

39. What Is Approval process?

Ans. Approval processes are used to automate the approval of records in Salesforce. For this a sequence of steps are defined and approval process automatically assign each requests to right person.

40. Once the approval process is configured can we add one more step?

Ans. We cannot add another step however we can deactivate and clone the current approval process and then add another step to the new process. Once done we can activate it.


Salesforce Interview Questions

41. What is trigger?

Ans. Triggers are code blocks that are used to perform certain actions based on DML operations (insert, update, delete, undelete) of records.

42. What are the categories of Trigger?

Ans. Triggers are mainly categorized as:

  1. Before Trigger : These kinds of trigger are used to validate or make changes to the record values before they are saved into the database.
  2. After Trigger: access field values that are set by the system like record Id or CreatedBy field, and to affect changes in other records.

43. What are the different trigger events?

Ans. Trigger syntax requires events to pass as parameter. These events decide when to call the trigger before or after the specified DML operations. Below are the main trigger events:

  • before insert
  • before update
  • before delete
  • after insert
  • after update
  • after delete
  • after undelete

44. What are context variables in a trigger?

Ans. Trigger context variables helps the developer to access the run-time context. Below are the main triggers context variables and their uses:




Returns the value true if this trigger was fired as a result of  an insert operation


Returns true if this trigger was fired as a result of an update operation


Returns true if this trigger was fired as a result of a delete operation


Returns true if this trigger was fired before any record got saved.


Returns true if this trigger was fired after all records got saved.


Returns true if this trigger was fired after a record is restored from the Recycle Bin


Returns a list of new versions of the sObject records.


Returns a map of IDs to the new versions of the sObject records.


Returns a list of  old versions of the sObject records.


Return A map of IDs to the old versions of the sObject records.


Provides the total number of records in a trigger invocation, both old and new.

45. Suppose there are two triggers written on Account object T1 and T2. Both triggers have a before event, if a record if inserted which Trigger will be executed first?

Ans. In case of multiple triggers on the same object and having same event order of execution is not guaranteed.  

46. How many triggers can be defined for an object?

Ans.  There is no limit on number on triggers to be created for an object but it is recommended to create only one trigger per object because the order of execution cannot be guaranteed in case of multiple triggers.

47. What is recursive trigger? What can be done to avoid it?

Ans. If a trigger calls itself it could result in a never ending loop, this condition is called Recursive trigger.

The most efficient way to avoid recursive trigger is by using a static Boolean variable and defining it with value true. Before executing the code block check the value of variable and then make it false.

48. What do you mean by Bulkifying a trigger?

Ans. This concept is to make sure that a trigger is able to handle more than one record at a time. This is very important because if the trigger is not bulkified and a bulk data is insterted/updated it will hit the governor limit.

49. What is the difference between trigger and Workflow?

Workflow Trigger
Workflow are point and click and does not require coding. Triggers are Code block written to perform certain actions.

Workflow rules cannot be used to perform DML operations

We  can perform up to 20 DML operations in one trigger.

Workflow  actions are done based on evaluation criteria and rule defined. Trigger works on DML operations

Workflow cannot be used to perform SOQL query

Triggers can be used to perform SOQL query

Child record cannot be updated when a parent record in updated

This is feasible using trigger

Workflow works only after certain action like insert, update

Triggers works both before and after DML operations like beforeinsert, afterinsert

Read Apex Trigger Blog for indepth and complete knowledge of Trigger.

Reports and Dashboards

Salesforce Interview Questions

50. What is a report in Salesforce?

Ans. Reports is a list of records based on the filters applied by user. These records are displayed with rows and columns and can be filtered, grouped and even displayed as graphical charts. Each report is stored in a report folder which can be public, hidden or shared with users.

51. How many formats of reports are there in Salesforce?

Ans. There are Four formats of reports in Salesforce :

  1. Tabular: These reports are the simplest reports which are used to display records in a spreadsheet fashion where a column shows the fields and each row represents a record. They cannot be used to create dashboards.
  2. Summary: These reports are similar to tabular reports and it also allows user to group rows of data, subtotals and create charts. They are also important while creating dashboards.
  3. Matrix: Matrix reports allow to group and summarize data by both rows and columns. They can also be used to create dashboards.
  4. Joined reports:  These reports are mainly used to create a report with multiple report types .

52. What are the limitations of Joined reports?

Ans. There are two main limitations of a Joined reports:

  1. Joined reports do not show more than 2,000 records.
  2. There is no option to extract reports in CSV or XLS format

53. How many blocks can be created in a Joined reports?

Ans. 5 blocks

54. Explain custom report types?

Ans.  Each report in Salesforce is created by selecting a report type. Some of the report types are created by default because of selecting “Allow reporting” checkbox while creating the objects, these are Standard report types.

But due to business requirement we might need to create a report type, these custom made report types are called custom report types. It can be created using both standard and custom objects.       

Note: Report types are created with related objects only.

55. How many records are displayed on a page for a report?

Ans. Up to 2000 records is displayed on a page, to see more records you will need to export the report. Joined reports do not have option to export so printable view can display 20,000 records.

56. What is dashboard in Salesforce?

Ans.  Dashboards are graphical representations of a report. A dashboard shows data in the form of charts, gauges, tables, metrics or Visualforce pages.

57. How many report components can be used in a dashboard?

Ans. Each dashboard can have a maximum of 20 components.

58. Can we schedule a dynamic dashboard in Salesforce?

Ans. Dynamic dashboard always show data in real time hence we cannot schedule a dynamic dashboards.

Data Loader and Import Wizard

Salesforce Interview Questions

59. What is data loader?

Ans. Data loader is an application which is used to perform bulk DML operations on records. These operations are insert, update, upsert, delete and also to export Salesforce records. We can process upto 5 million records using data loaders.

60. What is the format of filed mapping generated in data loader?

Ans.   .SDL

61. What settings are required to insert null values using data loader?

Ans. Go to settings of the data loader and check “insert null values”. Make sure to uncheck this after the work is done so that you do not insert a null record unintentionally.             

 62. What are the minimum and maximum batch size that can be set in the data loader?

Ans. Minimum batch size is 1 and the maximum batch size is 10,000. The default batch size selected is 200

63. What Is the default batch size of the data loader is bulk API is selected?

Ans. 2,000

64. What is import wizard?

Ans. Import wizard is also used to perform DML operations on records in Bulk. It can process only 50,000 records at maximum.

Asynchronous Apex

Salesforce Interview Questions

65. Explain Asynchronous Apex?

Ans.  Asynchronous apex is used to execute the actions in a separate thread when the resources are available.  These actions are executed in the background and user does not have to intervene in the process.

66. What are the different ways of calling asynchronous apex?

Ans. Below is the different ways to call asynchronous apex:

  1. Future Methods
  2. Queueable Apex
  3. Apex Scheduler
  4. Batch Apex

67. What is future method and what is the user of @future annotations?

Ans. Future methods are used to execute the process in a separate thread when the resources are available. To define a method as a future method we use @Future annotation.  These methods must be static and the return type will always be void.

68. Explain Queueable Apex?

Ans. Queueable apex’s concept is similar to future methods except this is for whole Apex class and not for just few methods. The Apex class defined as Queueable will be executed when the resources will be available.Unlike Future methods, Queueable apex also provides an option to monitor the progress of the code.

69. What is the syntax of Queueable Apex?

Ans .   

  public class class_Name implements  Queueable {

        public void execute ()



And to enque the job use:

Id JobID= System.EnqueJob(new class_Name());

70. What is Apex Scheduler?

Ans. Apex Scheduler is used to run the apex class at a scheduled time and regular intervals. To implement this Schedulable interface should be defined for the class and then the Schedule is required to be defined.


Public class class_Name implements Schedulable {

Public void execute (SchedulableContext  sc)  {




To Schedule this Go to:

Setup --> Develop--> Apex Classes --> Schedule Apex

71. Explain Batch Apex?

Ans. As the name Batch suggests, Batch Apex divides a complex work into small batches.  Batch Apex can process 50 million records asynchronously.  

72. What are the three methods used in Batch Apex?

Ans. There are three methods of Batch Apex:

  • Start Method makes the data ready for batches.


global (Database.QueryLocator | Iterable<sObject>) start(Database.BatchableContext bc) {}
  • Execute Method execute the actual action on the chunk of data


global void execute(Database.BatchableContext BC, list<P>){}
  • Finish Method is used to perform any action at the end of processing all records like o send confirmation emails or execute post-processing operations


global void finish(Database.BatchableContext BC){}

73. How can we Schedule batch apex in minutes/hours?

Ans. We would need to write code in the finish method and use System.schedule method which will take 3 parameters Job Name, Chrone Expression and schedulable class instance name respectively.

   /* Scheduling in minutes or hours */

  //Create object for schedulable class

  SchedulableUsage x = new SchedulableUsage();

  //Preparing chron_expression

  Datetime sysTime = System.now();

  sysTime = sysTime.addminutes(6);

  String chron_expr = '' + sysTime.second() + ' ' + sysTime.minute() + ' ' +

  sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year();           

  System.schedule('Dep Update'+sysTime.getTime(),chron_expr, x);

74. Is it possible to call another batch class from a batch class?

Ans. Yes we can call a batch class from another batch class by using Database.executeBatch or System.scheduleBatch in the finish method.

75. Is it possible to call a future method form a batch class?

Ans. No, we cannot call any asynchronous process from another asynchronous process.

 76. How many batch jobs can be active or queued at a time in the org?

Ans. 5

Apex Test Class

Salesforce Interview Questions

77. Why do we need to write test classes?

Ans.  As we know Salesforce works on multi-tenant architecture, so the resources should be used efficiently. Test classes are used to make sure that our code are actually getting executed and not just exploiting the resources. At least 75% of the class should be covered then only it can be deployed to Production.

78. What are the best practices a developer can follow to write a test class?   Ans.

  • IDs should not be hard coded for any sObject in test methods.
  • Name of test class must be appended with test keyword at the end of the class name. example MyClassNameTest
  • Test class should start with @Test annotation
  • Code coverage should be at least 75% to be deployed in Production.
  • Use isTest(SeeAllData = true) on class methods in exceptional cases only where the sObjects don’t allow DML operation e.g. PriceBook creation.
  • Any asynchronous method testing should include Test.startTest and Test.stopTest. Test.stopTest

79. What is the use of seeAllData in test class?

Ans. IsTest(SeeAllData=true) is used to open up data access to the records of the org. We should avoid using this annotation because in Sandbox the test class will depend on certain records and it is not necessary that those records will be available in production too thus causing the problem while deployment.

80. What is the use of Test.startTest() and Test.stopTest()?

Ans.  Test.startTest() and Test.stopTest() methods are used to provide a fresh set of governor limits to the code executing within these methods. These are very help full if the test class has DML or SOQL statements. These methods are also helpful while writing test class for Asynchronous Apex.

81. What is the use of system.runAs()?

Ans. Test class generally runs in system mode where the permissions and record sharing of the current user is not taken into consideration. System.runAs() method helps to change the context to an existing or new user to enforce record sharing.  runAs method enforce only record sharing only neither FLS nor user permissions.  

82. What are Assert statements and why do we use them?

Ans.   Assert statements are used to compare the expected value and the actual value in a test class. Assert statements are helpful in verifying the business logic defined in the apex class.

 These are the main assert statements used in a test class:

  1. assertEquals(v1,v2): test class will run successfully only if the two values v1 and v2 are same.
  2. assertNotEquals(v1,v2): test class will run successfully only if the two values v1 and v2 are same.
  3. assertEquals(v1> v2): test class will run successfully only if value v1 is greater than value v2

83. Why do we use @TestVisible?

Ans. @TestVisible annotation is used to allow test methods access to private/Protected members like methods, variables or inner class of another class. These access are provided only for running tests. 

Salesforce Interview Questions

Do let me know in comments if you need more interview questions and from which category.


Anonymous · July 20, 2020 at 10:29 pm

Q. Consider a scenario where we have two workflow rules WF1 and WF2 on Account object. If WF1 fires and if updates a field and now the criteria for WF2 is matched. Will the workflow WF2 fire or not?

I have created two WF1 and WF2 workflow Rule on contact object and define same criteria int both workflow rule and enable “re-evaluate workflow after change field” on WF1 workflow . but here both workflow are fire.
Can you please help me .

    Nilesh Raj · July 21, 2020 at 6:40 am


    I do not have the complete detail from you, but I assume, there are two workflows with the same criteria and it might be updating two fields based on which you are saying both workflows are getting fired.

    Re-evaluate workflow works if the condition does not meet initially and after the update if the condition meets and if you have selected the re-evaluation, other workflows whose conditions just got matched will fire again.

    But here in your case, the condition of both workflow is meeting in the first place only, so both will fire without a doubt. Which one will fire first, you cannot decide.

    Also, read question number 36 and 38 for clarity on recursive workflow.

    hope, it will help. Cheers!!!

Ajay Kumar · August 6, 2020 at 2:00 pm

Person who is above in role hierarchy doesnt have any permission in profile level for a particular object but his sub ordinate who is below in role hierarchy have permission to create record. In this case, person who is above in role hierarchy can able see, edit or create a record or not for particular object. OWD setting is public read write transfer.

would you please help me.

    Nilesh Raj · August 6, 2020 at 2:41 pm

    When OWD is public Read/write Transfer, there is no use of Role Hierarchy….any user can see others data…

    But if a user doesn’t have access on the object level(through profile) he will not be able to perform any activity. not even Read the data..

    Because object level access > record level access.

    Hope it answers your question.

Did you Like the content? Let me know

%d bloggers like this: