Tuesday, December 20, 2022

Salesforce Developer Interview Questions & Answers

Platform Knowledge

1. What are governor limits? Please provide some examples.

Governor limits are resource utilization limits enforced on Apex by Salesforce to prevent run away processes from monopolizing resources. This is vital as Salesforce is a multi-tenanted environment, so run resources are shared. Examples of these are the number of SOQL queries, DML statements, and the number HTTP callout requests in a transaction.

READ MORE: Execution Governors and Limits

2. What programming languages can we use to customise a Salesforce instance?

The server side language used to customize Salesforce is called Apex, which has a syntax similar to Java. On the front end, we have several technologies, the main one being Lightning Web Components, followed by the older and now more niche Aura Components and Visualforce – all of which use HTML, CSS, and JavaScript in conjunction with Apex. We can also use Flow, which is a low code language to customize both the front end and the backend.

READ MORE: 12 Salesforce Apex Best Practices

3. What declarative tools can we use to customize a Salesforce instance?

The most basic declarative tool is custom fields and custom objects, which can be defined declaratively and allow us to customize an instance’s database schema. We can further customize objects through the use of page layouts, and Lightning app pages to declaratively customize the look and feel of a record’s page.

If we wish to create declarative automations, we should be using Flow, while Process Builder and Workflow Rules exist, these are being deprecated by Salesforce and so declarative automations should be created via Flow instead.

READ MORE: Salesforce to Retire Workflow Rules and Process Builder

4. When would we choose programmatic development over declarative?

Declarative tools excel when rapid development is required as, due to their nature, they allow rapid iteration and usually have shorter build times. In scenarios where the business logic required is relatively straightforward, with very few “gotchas”, it usually makes sense to take advantage of declarative tools with faster build time, which can translate to a cheaper build.

We would choose programmatic development when the requirements become more complex, such as in very specialized business processes which don’t lend themselves to Flows, etc. Other scenarios are where performance or user interface is of paramount importance.

One of the main advantages of running a coded solution is that performance will exceed that of a declarative solution due to the ability to use more specialized logic and removing overheads. This also applies to user interfaces as using a coded solution allows us to fully customize it to our requirements, whereas using declarative tools means we are stuck with what comes out-of-the-box – which may not provide the desired outcome.

READ MORE: Which Automation Tool Do I Use?

5. What is the Salesforce release model?

Salesforce has major updates three times a year, seasonally, in Spring, Summer and Winter. The specific dates for these vary, however, around 4-6 weeks before a release, sandbox instances are updated to allow for testing of any customizations in an org.

READ MORE: Salesforce Releases Archive: 2015-2022

6. What Salesforce supported development tools are there?

The main Salesforce supported development tool is the Salesforce Extensions for VS Code which utilizes the Salesforce Command Line Interface.

READ MORE: What is the Salesforce CLI? (And How to Use It)

7. What are three types of object relationship?

Lookup Relationship: Two records related to each other through one object (the child) having a lookup field which is pointing to the other (the parent).

Master-detail: Similar to a lookup relationship, however in this case the child record is considered the detail and the parent the master. This type of relationship changes some behaviours of the detail records, such as having sharing controlled by the master and allowing special rollup-summary fields to be created on the master.

Self: A lookup relationship which points to the same object type, allowing a hierarchy or chaining of records of the same type. However, a record cannot be related to itself.

Read more:

8. What is SOQL?

SOQL stands for Salesforce Object Query Language, and as the name suggests it is the main language used for performing queries against the database. While it has a similar syntax to SQL, there are a few key differences, mainly that SOQL is exclusively used for queries (i.e. SELECT statements).

It is used to retrieve data from a single object, and potentially those directly related to it. SOQL can be used both within Apex code – to query records for consumption by said code – or via the API and tools which use it – such as in data loading tools.

Apex Programming

9. What is required for deploying Apex code to a Production instance?

When deploying Apex code to production, there are three things which are required:

  1. All classes and triggers must successfully compile.
  2. Tests must cover at least 75% of all Apex code and there must not be any failures.
  3. All triggers must have at least 1% coverage.
READ MORE: Testing Best Practices

10. What’s the difference between queueable Apex, batch Apex and schedulable Apex?

All three are different ways of running asynchronous Apex code:

Queueable Apex: This is an async process which can be launched to run processing, callouts, etc. This is useful when trying to do processes in triggers which are long running, or simply unavailable, e.g. callouts.

Batch Apex: An Apex process which is designed to handle large numbers of records (up to 50 million) by processing them in smaller batches of 1 – 2000 records at a time.

READ MORE: Simple Guide to Batch Apex in Salesforce

Scheduled Apex: A process that is scheduled to run at a specific time and date. This can be customized to be repeatable, either by scheduling it through the UI, or via a CRON string within other Apex code.

11. What are the different events for an Apex Trigger?

Triggers are split into two main types: before and after.

Before triggers run before a record has been saved into the database – optimally used for same record calculations and validations. Whereas, after triggers run after the record has been saved, and should ideally be used for working on records other than the one invoking the trigger.

Triggers are then further broken down into the type of operation which invokes it. These are: insert, update, delete, and undelete. This allows the triggers to be customized to only be invoked when explicitly required.

12. What is a global Apex class?

A global Apex class is an Apex class which has been declared with the global access modifier. This means that the class is visible and usable by any Apex code running in any namespace. Global Apex class should rarely be used and only implemented when explicitly necessary, e.g. within managed packages or for Apex REST web services.

13. What is an Interface and why would we use one?

An interface is similar to a class, except none of its methods have an implementation. This is useful for abstracting method declaration from its specific implementation. A common example of this can be found with Batch classes, which implement the standard Salesforce interface of Database.Batchable.

Using interfaces signifies that a class will explicitly implement the methods defined in it, potentially allowing us to implement different behavior at run time based on context.

14. How can we allow Apex to be called by Lightning components?

To call Apex code from a Lightning Component, it first must be annotated with @AuraEnabled. This exposes the code to be called from within the components JavaScript. We can adjust the annotation a little further to indicate that the method supports caching by using the @AuraEnabled(cacheable=true) annotation instead.

READ MORE: AuraEnabled Annotation

15. How can we debug our Apex code?

When Apex code runs, we can generate debug logs for the executed code. These logs provide an insight into what happened during execution, any exceptions that were thrown, and also provide the details of anything passed into a System.debug() method call.

If we increase the logging levels sufficiently, we can also use the Apex Replay Debugger, which allows us to use VS Code to step through the code execution and examine it in more detail and set checkpoints and breakpoints for a more in-depth debugging experience.

READ MORE: Debugging Apex

Integrations

16. How can we integrate into external REST web services?

For integrating with external REST web services, we would tend to use HTTP callouts to invoke the external API. We can use the JSON and XMLStreamWriter classes to build payloads to match the specifics of the external API.

17. How can an external system integrate into Salesforce?

External systems can utilize the built in REST API provided by Salesforce for simple integrations. This could be for creating, updating, querying records. For more niche, or bespoke, inbound integrations.

READ MORE: Introduction to REST API

18. How can we secure credentials used for outbound integrations?

Depending on the type of credentials, we have a few options. The most preferred is Named Credentials which specify the base endpoint and the authentication credentials. These are preferred since Salesforce then handles the authentication for us and keeps the credentials away from prying eyes.

Alternatively, if named credentials are not suitable, we could choose to store the credentials in a Custom Metadata type, which will allow different credentials to be used across different environments and we can secure the permissions to access the metadata type. We should never be hard coding the credentials for integrations within our code as this is very insecure.

READ MORE: Named Credentials as Callout Endpoints

Lightning Components

19. What is the difference between Lightning Web Components and Aura components?

Lightning Web Components is built using current web standards to build custom HTML elements, through the use of Web Components – designed to run in a lightweight and performant manner. Aura components are the legacy Lightning Component framework, but still utilize JavaScript and HTML for development.

20. Why would we use Lightning Web Components over Aura components and vice versa?

Ideally, we should always be using Lightning Web Components for any new developments, due to their easier development and better performance. We should avoid using Aura components unless we wish to use a piece of functionality which is not yet supported in LWCs, in this case we should wrap an LWC inside of an Aura component.

Read more:

21. How can Lightning Web Components be made configurable by an Admin?

We can define our configurable properties in a components .js-meta.xml file. This is done by defining a property tag within the targetConfig tag for our specific target and can further be extended to only apply to specific objects, or to limit the objects which the component can be placed on.

22. Where can we use Lightning Components?

Lightning components can be deployed in a large number of places across an org. These can be admin decided ones or added by developers. These include:

  • The Utility Bar
  • Outlook and Gmail integrations
  • Flows
  • Visualforce pages
  • External web pages
  • Pre-chat snap-ins
  • Quick Actions
READ MORE: XML Configuration File Elements

23. What is SLDS?

The Salesforce Lightning Design System (SLDS) is the user interface design framework used by Salesforce for designing, styling, and building all aspects of Salesforce Lightning.

As developers, we can utilize the SLDS provided CSS styles or component markup templates to build custom components which provide a consistent UI with the rest of the platform. SLDS also provides guidelines around accessibility, language guidance, and icons.

READ MORE: Welcome to the Salesforce Lightning Design System (SLDS)

Secure Development

24. How can we enforce Field Level Security (FLS) within our Apex code?

There are a few approaches depending on the context of where we wish to enforce Field Level Security.

If we are performing a query, and do not require graceful handling of missing permissions, we can add the WITH SECURITY_ENFORCED clause to the query. This will cause an insufficient permissions exception to be thrown if any permissions to the requested fields are missing.

READ MORE: Filter SOQL Queries Using WITH SECURITY_ENFORCED

If we need more granularity or wish to simply remove fields a user does not have sufficient permissions for, we can use the Security.stripInaccessible() method. As the name suggests this method checks for, and removes any field values for, the specific context requested, e.g. removing fields which the user does not have permissions to update.

READ MORE: Enforce Security With the stripInaccessible Method

25. How can we enforce Sharing Rules within our Apex code?

We can define our class to use the with sharing keywords in its definition. Alternatively we can use the inherited sharing keywords, which inherits the sharing modifier from its calling class for when we need code that should handle this dynamically.

READ MORE: Using the with sharing, without sharing, and inherited sharing Keywords

26. When should we bypass sharing and FLS within our code?

We should only bypass these when we are running system level processes. If we do need to bypass them for user operations, we should be ensuring there is no chance data or actions which are unintended can be performed.

This could be by migrating the specific actions which require bypassing to separate classes and performing the rest of our logic with sharing and FLS enforced. We should only ever be bypassing it for specific actions, not an entire set of business logic.

27. How can we secure dynamic SOQL?

When we are performing dynamic SOQL which takes an input from a user, we must sanitize the user input. We do this by making sure all single quotes are escaped before performing the query. Alternatively, wherever possible, we want to use bind variables, even with our dynamic SOQL.

Configurable Development

28. What is a roll-up summary field?

Roll-up summary fields are special fields which lie on the master side of a master-detail relationship. These fields have their values calculated based on an aggregate of the detail side of the relationship – this could be anything from the number of records to a field value summed up. It allows us to skip using Apex when we wish to aggregate record values that are part of a master-detail relationship.

READ MORE: 4 Ways to Create Roll-Up Summary Fields on Lookup Relationships in Salesforce

29. What are Custom Metadata Types and why would we use them?

Custom Metadata Types are developer designed pieces of metadata which facilitate the designing and building of customizable applications within a Salesforce instance. This is done by first designing the metadata type, which is similar to a custom object, and then by creating records of that type to define the required behavior, by being read at run time. This could be anything from defining a field mappings table between two objects, to storing secrets for an API integration.

READ MORE: Introduction to Custom Metadata Types

30. What is dynamic Apex?

Dynamic Apex is a technique in which we make our code more flexible by accessing sObjects and fields dynamically, rather than declaratively, within our code. This is mainly done through the use of sObject tokens and describes to dynamically access and set sObject field values within our code. This can be used in conjunction with dynamic SOQL to dynamically build queries based on runtime context, rather than design time.

READ MORE: Dynamic DML

Salesforce Developer Interview Tips

When in an interview where your technical knowledge is being tested, simply regurgitating canned answers probably won’t make you stand out from the crowd. If you’re really interested in the role you’re interviewing for, a great way to make a great impression with the interviewer is to answer their questions and then go one further. Take the question and give the theoretical answer, but then expand upon it by providing some personal context to the answer.

For example, give an example of when you utilized the things you’re being questioned about and show the pros and cons of it. While this isn’t applicable for all questions, any of the more technical ones are a great opportunity to show off your knowledge by giving real scenarios where you’ve used what you’re talking about. This shows that you actually know your stuff and will definitely leave a good impression with the interviewer.

Another tip: don’t be afraid to admit if you don’t know or are not sure of a question they have asked. The Salesforce platform has such a huge scope, that knowing everything isn’t possible – we’re all guilty of a quick google every now and again!

Admitting you don’t know something can allow the interviewer to rephrase. Perhaps you’ve never heard it described that way before. It also shows that you’re aware of your own limits, and this will come across more positively than blagging and getting it completely wrong.

Summary

These Salesforce Developer interview questions are just some that may be asked in a technical interview. Every interviewer is different and will likely have a differing set of questions and their own style of interviewing, so it’s best to always go in with an open mind and be prepared to show off your technical knowledge. Good luck, and I hope you knock the socks off the interviewer!

No comments:

Post a Comment