Salesforce Interview Questions and Answers

Salesforce Interview Questions and Answers



1. How you’d control permissions through each of the following:

  • Profile – Object level control
  • Roles – Record access through hierarchy
  • Permission sets – Open up access to objects and records
  • Sharing Rules – Record level access through manual and apex sharing

2. How will you prevent a set of users from accessing a specific field?

Using profile. By removing field accessibility to the profile.

3. What is field Set?

Grouping of multiple fields is known as field set. It can be used in vf page by looping over the set.

4. What is WhoID and WhatID in salesforce?

WhoId refers to people things. WhatId refers to Object things.

5. Explain communities and sites in salesforce?

Using communities we can create a branded website for our customer, employees etc.

Using Sites, we can create a public webpage for external use.

6. Explain bucket fields?

To categorize records in report we can use bucket fields.

7. Which report types are available in Dashboard?

Matrix, Summary &Tabular

8. Explain Dynamic Dashboards?

Dynamic Dashboards are user-based dashboard. Contents will change as per user access.

9. How to bypass validation rules during data load?

By using a dummy checkbox and trigger.

10. Explain Salesforce Order of Execution?

  • The record is loaded from the database
  • The new record field values are loaded
  • All before triggers execute
  • System validation
  • The record is saved to database, but not yet the committed
  • All after triggers execute
  • Assignment rules execute
  • Auto-response rules execute
  • Workflow rules
  • If there are workflow field as updates, the record is updated into again
  • Escalation rules
  • All DML operations
  • Post-commit logic execution


11. Can we deactivate a time-based workflow? What are the impacts?

No, we can’t. Salesforce won’t allow to deactivate if there are any time trigger action.

12. How do you prevent two Opportunities from being created on a single Account in a single day declaratively?

Using validation rules.

13. How do you prevent closed Opportunities from being updated by a non-System Administrator profile declaratively?

Using sharing rules.

14. On each opportunity stage change, I want to display a new section on the page layout. How to achieve this?

Using Record types.

15. We have 2 workflows WF1 & WF2 on Case. WF1 updates a custom field which is the entry criteria for WF2. Will the WF2 fire?

If we enable “allow to call another workflow” then if WF2 will fire.


16. Under what scenario recursion will happen in triggers and how will you overcome?

Recursion will happen when we are trying to update same record multiple times in a single transaction. We can overcome it by using Boolean check.

17. Why do we need Batch Apex?

Batch Apex is one of the Asyn jobs. Using batch apex we can upsert/delete multiple records without affecting the heap size.

18. When to use public class and when to use global class?

By using public keyword, the class can be accessible throughout the app.

By using global keyword, the class can be accessible throughout the org.

19. Explain with sharing & without sharing keywords?

With Sharing keyword is used to enforce security/OWD access.

Without sharing keyword is used to allow the app to run without any OWD restriction

20. How do we schedule a batch apex?

Using apex scheduler and schedulable class.

21. How to call an apex method in javascript code?

Using @RemoteAction

22. Explain static field and their scope

Static field will initialize only once and has scope of the class.

23. Explain the difference between and trigger.newmap? – returns the list of latest records.

Trigger.newmap – contains the record IDs.

24. Can we enforce assignment rules via Apex code?


25. Can we lock a record via SOQL query?

Using FOR UPDATE keyword

26. How to reduce Apex heap size?

Avoid SOQL inside for loops, Use transition variables wherever possible.

27. Explain TestSetup annotation?

Using this we can create common records for test class to execute.

28. How do you cover the logic of asynchronous methods in test class?

By calling inside Test.Starttest and test.stoptest

29. Design Patterns used in Apex?

  • Singleton
  • Strategy
  • Decorator
  • Facade
  • Composite
  • Bulk State Transition

30. How will you achieve pagination in SOQL?

Using Offsets.


31. Explain actionFunction, actionRegion and actionSupport?

  • AcctionFunction is used to call apex method from JS.
  • Action support is used to call apex method on events like onclick,onhover etc.
  • Action region is used when AJAX request is called. Only the action region will execute during this request.

32. Explain ActionPoller?

Action Poller is used to achieve AJAX functionality in VF page.

33. Explain various types of controllers?

Standard and custom controllers.

34. Explain View State?

View state is the state of the vf page. Its limit is 135kb.

35. How will you pass values from vf page to controller?

Using apex:param.

36. What is vf component?

Vf component is used to invoke a set of functionality inside vf page. Using apex:component attribute we can invoke vf component.

37. I want to convert vf page to a pdf. How to achieve it?

By making renderasPdf to ‘true’ in apex:page attribute.

38. How will you to create a pie chart in vf page?

Using apex:chart attribute.

39. What is difference between datatable and pageblock table?

Pageblock table can be invoke only inside a page block. Data table can be invoke anywhere if vf page.

40. How will you call one vf page from another vf page?

Using apex:include attribute.


41. Difference between Rest and SOAP?

Rest is loosely coupled and be used for frequent transaction.

SOAP is tightly coupled and be used for bulk transaction.

42. Partner vs Enterprise WSDL?

Partner WSDL is static and loosely bind.

Enterprise WSDL is mainly for customers and tightly bind.

43. Can we expose our Apex class as a Web Service?

Yes. Using @Restsource

44. How do you write a test class for WS?

Using HttpCalloutMock interface.


45. What is the architecture of Lightning experience?

Event-driven architecture.

46. Is it possible to refer external styles and scripts in lightning? How?

Yes. Using <lntg:require> tag.

47. Explain Lightning AppBuilder? How will make sure that your lightning component available in App Builder?

Using flexipage:availableforrecordpage interface we can avail component in app builder.

App Builder is used to create lightning application declaratively.

48. Can we bind an existing Apex Controller with a lightning component?

Yes. Using @AuraEnabled.

49. How will you communicate between two components?

Using custom component events

50. What is the use force:hasrecordID?

It’s used to enable the component to be assigned the ID of the record.