Recently asked Salesforce interview questions
Open-ended developer scenarios reported from interviews over the last year, with the options to mention and the one to pick.
These scenario questions are reported by Salesforce developers with three to five years of experience from interviews over the last year. Each one is open-ended on purpose: the interviewer wants to hear the options you considered and why you picked one.
These are questions that candidates say they were asked in recent interviews. Companies do not publish official question lists, and every team asks differently, so use this page to practise the style of question, not to memorise answers.
Integration and security
01Salesforce must call a payment gateway securely. How do you do it?
Salesforce must call a payment gateway securely. How do you do it?
Store the endpoint and credentials in a Named Credential with an External Credential, so no secret is in code and access is controlled with a permission set. Use OAuth 2.0 if the gateway supports it; the JWT bearer flow is good for server-to-server calls because no password is stored, only a certificate. Never log card data; send only what the gateway needs, ideally a token, and keep card numbers out of Salesforce altogether.
02An external system calls the Salesforce API thousands of times a day and hits rate limits. What do you do?
An external system calls the Salesforce API thousands of times a day and hits rate limits. What do you do?
Reduce the number of calls rather than asking for more:
- Send records in groups with the Composite or sObject Collections APIs (up to 200 records per call), or Bulk API 2.0 for large loads.
- Subscribe to changes with Change Data Capture or platform events instead of polling.
- Cache data that rarely changes on the external side.
- Check the API usage in Setup to find which user or app is the heavy caller.
03An external system calling Salesforce times out now and then. How do you troubleshoot?
An external system calling Salesforce times out now and then. How do you troubleshoot?
Find out where the time goes: check the event log or debug logs for the API calls and see whether the Salesforce side is slow (long Apex, triggers, flows, locks) or the network is. If the work is heavy, accept the request quickly, then process it asynchronously and let the caller check the status later. The caller should retry with backoff and send an external Id, so a retry does not create a duplicate.
04You store sensitive data such as personal ID numbers. How do you protect it?
You store sensitive data such as personal ID numbers. How do you protect it?
First ask whether you need to store it at all. If you do: use Shield Platform Encryption for data at rest, field-level security so only the right users see the fields, and restrict access to reports and exports. Mask the values in the UI where people only need part of them. Event Monitoring shows who viewed or exported data. Card numbers should not be stored in Salesforce; use the payment provider's tokens.
05Users need a single sign-on into Salesforce. SAML or OpenID Connect?
Users need a single sign-on into Salesforce. SAML or OpenID Connect?
Both work. Use SAML if the company's identity provider is set up for it, which is common with Microsoft Entra ID, Okta and ADFS. Use OpenID Connect when the provider is OAuth-based, such as Google, or for customer and partner logins on Experience Cloud. Either way, Salesforce is the service provider and the user's password stays with the identity provider.
Apex and data
06Your Apex often fails with "Apex CPU time limit exceeded". How do you fix it?
Your Apex often fails with "Apex CPU time limit exceeded". How do you fix it?
Find the slow part first with the debug log's timeline or Limits.getCpuTime(). Common causes are nested loops (use maps instead), too many triggers and flows on the same object, recursion, and heavy JSON or string work. Move work that does not need to finish now into Queueable or Batch Apex, or publish a platform event and do it in a subscriber. SOQL and DML time does not count toward CPU time, so the problem is usually in the logic, not the queries.
07Roll up the total of Opportunity Line Items into a custom field when a roll-up summary field is not possible. How?
Roll up the total of Opportunity Line Items into a custom field when a roll-up summary field is not possible. How?
In an after trigger on OpportunityLineItem (insert, update, delete and undelete), collect the parent opportunity Ids, run one aggregate query (SELECT OpportunityId, SUM(TotalPrice) ... GROUP BY OpportunityId) and update the opportunities in one DML. Opportunities with no lines left must be set to zero. A record-triggered flow can do the same for smaller volumes. For huge volumes, a nightly Batch Apex recalculation is a safety net.
08Delete an account's contacts when it is deleted, but only if a flag on the account is true. How?
Delete an account's contacts when it is deleted, but only if a flag on the account is true. How?
Watch out: by default Salesforce already deletes an account's contacts when the account is deleted. So the real job is to keep the contacts when the flag is false.
Use a before delete trigger on Account. For accounts where Delete_Contacts__c is false, query their contacts and move them before the account goes, for example to a holding account or by clearing AccountId (which makes them private contacts). For accounts where the flag is true, do nothing and let the standard cascade delete them. Bulkify the trigger, and agree with the business where kept contacts should live.
09The standard auto number field does not meet the numbering rule. How do you build your own?
The standard auto number field does not meet the numbering rule. How do you build your own?
Store the last number in a record (for example a custom object or a custom setting) and, in a before insert trigger, lock that record with SELECT ... FOR UPDATE, add one, assign the numbers to the new records and save the counter. The lock stops two transactions from taking the same number at the same time. Keep the locked section short, because other users wait for it.
10A dynamic query in your Apex is open to SOQL injection. How do you fix it?
A dynamic query in your Apex is open to SOQL injection. How do you fix it?
Switch to static SOQL with bind variables, or pass a map of binds to Database.queryWithBinds(). Allow-list any field or object names that come from the user. Also query in user mode, so the query respects the user's sharing and field access.
11Users need a search page with many optional filters. How do you build it?
Users need a search page with many optional filters. How do you build it?
Use SOSL when users type free text across several objects; it is fast and searches indexed text. Use SOQL built from the filters when users pick specific values, adding a condition only for filters they filled in and binding every value. Return only the columns you display, use LIMIT and paging, and filter on indexed fields where possible.
Reports, automation and UI
12A sales team wants a report emailed every week. How?
A sales team wants a report emailed every week. How?
Subscribe them to the report. A report subscription sends the results by email on the schedule you choose, and can include conditions such as "only if pipeline is below target". Apex scheduled jobs are only needed for formats subscriptions cannot produce.
13Reports over millions of records are slow. How do you speed them up?
Reports over millions of records are slow. How do you speed them up?
Make filters selective: filter on indexed fields and narrow date ranges. Avoid complex cross filters on large objects. Use reporting snapshots to save summaries on a schedule, so users report on a small summary object instead of millions of rows. For heavy analysis across very large or external data, CRM Analytics or Data 360 is the better tool.
14Approval levels must change with the deal amount, for example manager approval above 10,000. How?
Approval levels must change with the deal amount, for example manager approval above 10,000. How?
One approval process with several steps, each with its own entry criteria: step 1 for amounts over 10,000 goes to the manager, step 2 for amounts over 100,000 goes to the director. Use the manager field on the user record so approvers are dynamic, and set delegated approvers for holidays. Flow approval processes are an option for more complex or parallel approvals.
15Users must be able to upload very large files. What are your options?
Users must be able to upload very large files. What are your options?
Salesforce file storage is limited and expensive, so for very large or numerous files, store them in an external service such as Amazon S3 and save only the link and metadata in Salesforce. Upload directly from the browser to the storage service with a short-lived signed URL, so the file never passes through Apex heap limits. Within Salesforce, lightning-file-upload handles normal files without custom code.
16Users should only see records in their sales territories. How?
Users should only see records in their sales territories. How?
Use Enterprise Territory Management: define territories and assignment rules for accounts, assign users to territories, and set the territory access levels for accounts, opportunities and cases. Territory sharing works alongside the role hierarchy and sharing rules, so it fits matrix sales teams where one account belongs to several territories.