SALESFORCE INTEGRATION
CODING QUESTIONS
www.prominentacademy.in
+91 98604 38743
Question:
You're calling a REST API from Salesforce that returns data in
paginated format. How do you handle pagination and collect
all data?
Expected Logic:
Call the first page.
Check if there’s a next URL or page number.
Loop or recursively call until all pages are retrieved.
apex
public class PaginatedAPIHandler {
public static void fetchAllPages(String url) {
Http http = new Http();
Boolean hasMore = true;
while(hasMore) {
HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');
req.setHeader('Authorization', 'Bearer YOUR_TOKEN');
HttpResponse res = http.send(req);
Map<String, Object> responseMap = (Map<String, Object>)
JSON.deserializeUntyped(res.getBody());
List<Object> records = (List<Object>) responseMap.get('data');
// Process records
System.debug(records);
if(responseMap.containsKey('nextPageUrl')) {
url = (String) responseMap.get('nextPageUrl');
} else {
hasMore = false;
}
}
}
}
Your next opportunity is closer than you think. Let’s get you there!
📞 Don’t wait—call us at +91 98604 38743 today
Question:
Can you make an external API callout directly from a trigger?
Correct Answer:
No. Triggers are synchronous.
Must use @future or Queueable methods.
apex
trigger AccountTrigger on Account (after insert) {
for(Account acc : Trigger.new) {
CalloutService.makeAsyncCallout(acc.Id);
}
}
public class CalloutService {
@future(callout=true)
public static void makeAsyncCallout(Id accountId) {
// Perform callout here
}
}
Common Mistakes:
Direct callout in trigger → runtime error
Calling @future method from another @future method →
governor violation
Not filtering records properly before calling
Your next opportunity is closer than you think. Let’s get you there!
📞 Don’t wait—call us at +91 98604 38743 today
Scenario:
You're consuming a third-party API where the response
structure may vary slightly (e.g., optional keys, nested objects).
Expected Logic:
Use JSON.deserializeUntyped() for flexibility.
apex
HttpResponse res = http.send(req);
Map<String, Object> result = (Map<String, Object>)
JSON.deserializeUntyped(res.getBody());
if(result.containsKey('data')) {
List<Object> dataList = (List<Object>) result.get('data');
for(Object item : dataList) {
Map<String, Object> dataItem = (Map<String, Object>) item;
System.debug('Item: ' + dataItem.get('name'));
}
}
Common Mistakes:
Using a strict Apex class when the structure is dynamic
Null pointer exceptions when keys are missing
Not validating data before casting
Your next opportunity is closer than you think. Let’s get you there!
📞 Don’t wait—call us at +91 98604 38743 today
Scenario:
You’re integrating with a flaky system that fails intermittently.
How do you handle this?
Expected Pattern:
Use Database.SaveResult.isSuccess() or
HttpResponse.getStatusCode()
Retry logic using Retry Count field in a custom object
Optionally use Platform Events for async retries
apex
Integer attempts = 0;
while(attempts < 3) {
try {
HttpResponse res = http.send(req);
if(res.getStatusCode() == 200) {
break;
}
} catch(Exception e) {
attempts++;
if(attempts == 3) {
// Log error to Integration_Error__c
}
}
}
Common Mistakes:
No retry mechanism implemented at all
Exceeding callout limits with retries inside loops
Not implementing exponential backoff
Your next opportunity is closer than you think. Let’s get you there!
📞 Don’t wait—call us at +91 98604 38743 today
Scenario: Update a record in Salesforce via an external REST
API. What Apex code would you write?
Logic:
Receive the API call (Apex REST class with @HttpPatch)
Extract record ID and data
Use DML to update the record
apex
@RestResource(urlMapping='/updateContact/*')
global with sharing class UpdateContactAPI {
@HttpPatch
global static String updateContact(String body) {
Contact c = (Contact) JSON.deserialize(body, Contact.class);
update c;
return 'Contact updated with ID: ' + c.Id;
}
}
Common Mistakes:
Forgetting to check if the record exists before updating
Not handling partial updates (PATCH should be partial)
No error handling or null checks
Your next opportunity is closer than you think. Let’s get you there!
📞 Don’t wait—call us at +91 98604 38743 today
Explain how Platform Events are used for integrations
Use Case:
Salesforce → External system (event-driven integration)
Logic:
Define a Platform Event
Publish it in Apex
External system subscribes via CometD/Bayeux
apex
Account_Integration__e event = new Account_Integration__e(
AccountId__c = acc.Id,
Name__c = acc.Name
);
EventBus.publish(event);
Common Mistakes:
Not handling replay IDs in external systems
Publishing too many events (governor limits)
Not retrying on failure
Your next opportunity is closer than you think. Let’s get you there!
📞 Don’t wait—call us at +91 98604 38743 today
Think your skills are enough?
Think again—these salesforce
questions could cost you your
Salesforce job.
Looking to crack your Salesforce interviews and land
your dream job? 💼 We've got you covered! At
Prominent Academy, we specialize in providing end-to-
end interview preparation that ensures you're not just
ready—but confident! 💪
💡 What We Cover:
✅ Mock Interviews tailored to Salesforce roles
✅ Real-world scenario-based questions for Admin,
Developer, CPQ, and Architect tracks
✅ Guidance on resume building and LinkedIn
optimization
✅ In-depth coverage of Salesforce core concepts,
integrations, and projects
✅ Latest Salesforce certification tips and tricks
✅ Unlimited interview calls with top companies
🎯 Whether you're a fresher or an experienced
professional transitioning to Salesforce, we provide
personalized guidance to help you shine in interviews and
stand out in the competitive market
📞call us at +91 98604 38743 to learn more.