Have a question?
Message sent Close

Scenario Based Salesforce Integration Interview Questions

1. You are working on integrating Salesforce with Sizmek, an external campaign management system. When a campaign is created in Sizmek, it needs to be automatically created and updated in Salesforce, including updating the campaign hierarchy. How to achieve this?

1/ First step is to breakdown the requirement and understand the data flow.

  • A campaign is created in Sizmek.
  • Sizmek sends a request to Salesforce to create the campaign.
  • Salesforce creates the campaign and updates the hierarchy if necessary.
  • Salesforce responds back to Sizmek with the status of the request.

2/ This is a call-in where Sizmek (external system) calls Salesforce to perform operations.

img55

3/ Connected App Setup:

  • Create a Connected App in Salesforce to enable OAuth authentication.

img56

img58

  • Obtain the Client ID and Client Secret for authentication.

img59

4/ OAuth Authentication:

  • Implement OAuth 2.0 user-agent flow in Sizmek to obtain an access token. The user-agent flow is simpler and more straightforward. It reduces the need for server-side handling of OAuth tokens.
  • Use this access token to authenticate API requests to Salesforce.

5/ Connector in Sizmek:

  • Set up the connector with the necessary API user details through the OAuth flow.

6/ Using Standard REST API:
Make HTTP POST requests to the Salesforce REST API /sobjects/Campaign/ endpoint to create and update campaign records.
No need to write a custom Apex REST class for this purpose.

2. Quotes created in Salesforce (with Apttus package) need to be fetched by SAP CRM at the end of the day and created in SAP CRM. How to achieve this scenario?

1. Data Flow:

  • A quote is created in Salesforce.
  • At the end of the day, SAP CRM fetches all created quotes from Salesforce.
  • The fetched quotes are then created in SAP CRM.

2.Type of Integration: This is a call-out from Salesforce to SAP CRM to fetch and synchronize data.

img61

3.Solution: Use a custom REST API to expose the necessary data.

Steps
1. Create an Apex Class for Callout. You can use future or batch or queuable depends on scenario.

Future Methods: Would be ideal for small, quick updates that don’t require monitoring.

Limits:

  • Maximum of 50 future calls per transaction.
  • Maximum of 200 future calls per 24-hour period per license.
    Sample Code

img001

Queueable Apex: Suitable for handling complex logic and chaining jobs if the integration requires multiple steps.
Limits:

  • Maximum of 50 Queueable jobs per transaction.
  • Maximum of 200 jobs added to the queue per 24-hour period per license.
  • Limit of 100 enqueued jobs at once for an org.

Sample Code

img002

Batch Apex: Best for nightly or periodic syncs where a large volume of data needs to be processed.

Limits:

  • Maximum of 5 active batch jobs at a time.
  • Maximum of 100 batch jobs can be queued or active concurrently.
  • Up to 2000 batch apex jobs can be submitted in a 24-hour period.
  • Each batch can process a maximum of 50 million records.

Sample Code

img003

img004

2. Schedule the callout to run at the end of the day using a Scheduled Apex class.

Sample Code

img005

3.Scheduling the Job:
Use the Salesforce user interface or Developer Console to schedule the job.

img006

3. Products are created in Informatica, and these products need to be imported into Salesforce on a nightly basis? Explain how you would achieve this integration?

1. Data Flow:

  • Products are created in Informatica.
  • A nightly batch job runs in Informatica to extract the newly created or updated products.
  • Informatica sends a REST API call to Salesforce to insert or update the product records.
  • Salesforce processes the incoming data and updates its product records accordingly.

2. This is a Call-In:

Informatica (external system) will call Salesforce to perform operations (insert/update products).

3. Connected App Setup:

  • In Salesforce, create a Connected App to enable OAuth authentication.
  • Obtain the Client ID and Client Secret for authentication.

4. OAuth Authentication:

Implement OAuth 2.0 user-agent flow in Informatica to obtain an access token. This flow is simpler and reduces the need for server-side handling of OAuth tokens.

5. REST API Endpoint:

Informatica will use Salesforce’s standard REST API to insert or update product records. Salesforce’s standard REST API endpoints, such as /sobjects/Product2/, are designed for common CRUD (Create, Read, Update, Delete) operations on Salesforce objects. Informatica will send HTTP POST requests to the Salesforce REST API /sobjects/Product2/ endpoint to insert or update product records.

4. Every night, Informatica runs a batch job to extract newly created or updated products. These products need to be automatically created or updated in Salesforce, and for each product, a corresponding price book entry and inventory record also need to be created or updated. How would you achieve this integration?

When a product is created, a corresponding price book entry and inventory record also need to be created or updated. We would have used custom logic instead of standard REST API in following scenario.

1. Connected App Setup

  • Create a Connected App in Salesforce to enable OAuth authentication.
  • Obtain the Client ID and Client Secret for authentication.

2. OAuth Authentication

  • Implement OAuth 2.0 user-agent flow in Informatica to obtain an access token.
  • Use this access token to authenticate API requests to Salesforce.

3.Create the Custom REST API:

  • Define an Apex class with a @RestResource annotation to handle the API requests.
  • Implement the logic to create or update the product, price book entry, and inventory record within this class.

img007

4. Informatica REST API Call

– Use Informatica to send HTTP POST requests to the custom REST API endpoint in Salesforce to insert or update product records.

When to Use Custom REST API vs. Standard REST API

Standard REST API: Use for simple CRUD operations where no additional logic or complex relationships are involved.

Custom REST API: Use when you need to perform additional logic or handle complex relationships like creating multiple related records (e.g. product, price book entry, and inventory record).

5. You need to display the number of orders associated with an account in Salesforce without actually storing the order data in Salesforce. How to achieve this?

This can be achieved using Salesforce Connect and External Objects.

1. Data Flow

  • Orders are stored in an external system.
  • Salesforce needs to display these orders without storing them.
  • Use Salesforce Connect to integrate and display external data as External Objects in Salesforce.

2. Salesforce Connect Overview Salesforce Connect allows you to access data stored in external systems without importing the data into Salesforce. Use External Objects to represent the data in Salesforce. The data remains in the external system but is accessible within Salesforce.

3. Define External Data Source

  • Go to Setup in Salesforce.
  • In the Quick Find box, enter External Data Sources and select it.
  •  Click New External Data Source
  • Fill in the required details

img71

4. Validate and Sync External Data Source
1.Click Validate and Sync

img72

2. Select the tables or entities from the external system that you want to sync (e.g: Orders).
3. Click Sync to create the External Objects in Salesforce.

img74

Configure External Objects
1. Go to Setup
2. In the Quick Find box, enter External Objects and select it.
3. Find the External Object created during the sync process (e.g., Orders).
4. Configure the fields and relationships as needed.

img75

Display Orders in Account Page
1.Create a Lookup Relationship field on the External Object to link it to the Account object. It is Indirect Lookup Relationship. It links a child External object to a parent Standard or Custom object.
Here an Order (External Child Object) associated with Account (Standard Salesforce Parent Object).

img77

img78

2. Go to Object Manager in Salesforce.
3. Select Account and then Page Layouts
4. Edit the page layout to include a related list for the External Object (Orders).
5. Save the layout.

6. You are working on integrating Salesforce with SAP CRM. Both Salesforce and SAP CRM manage quote records. The integration needs to handle the following: 1. Real-time Updates: When a quote is updated in Salesforce, the change should be sent instantly to SAP CRM. 2. Nightly Creations: New quotes created in Salesforce should be sent to SAP CRM at the end of the day in a batch. How will you achieve this scenario?

Here We need to focus on Real time updates and Nightly creation of Quotes. This scenario will help us learn when to use which approach.

Real-time Updates: The trigger on the Quote object will use a future method to handle callouts for real-time updates, ensuring the callout does not block the main transaction.

Nightly Creation: Batch Apex handles new quote creations by collecting all new quotes created during the day and sending them to SAP CRM in a single batch, scheduled to run nightly.

1.Real-time Update Using Future Methods
When a quote is updated in Salesforce, a future method will be used to make a callout to SAP CRM. This ensures the update is sent to SAP CRM in real-time.

1.Create an Apex trigger that listens for updates on the Quote object.
2. Define a future method to handle the callout to SAP CRM.

Apex Trigger:
Sample Code

img008

Future Method
Sample Code

img009

img0010

2. Nightly Creation Using Batch Apex
New quotes created in Salesforce during the day should be sent to SAP CRM in a batch at the end of the day. This can be scheduled to run nightly.

  1. Batch Apex Class: Create a Batch Apex class to collect and send new quotes.

Sample Code

img0011

img0012

2. Schedulable Class: Schedule the batch class to run nightly.

img0013

Schedule this class to run nightly

img0014

7. When a Quote record is updated in Salesforce, it should be updated in SAP, Azure, and AWS. How will you achieve this scenario?

Since this involves multiple systems, point-to-point integration is not efficient. Instead, using Platform Events for a 1-to-many integration is the ideal solution. This approach leverages the event-driven architecture of Salesforce and ensures that all connected systems receive the necessary updates in real-time.

1. Define the Platform Event:

  • Create a Platform Event in Salesforce to capture the Quote updates.
  • Add necessary fields to the Platform Event to hold the Quote data.

2. Publish Platform Event:
Update the Quote trigger to publish the Platform Event whenever a Quote record is updated.
3. Subscribe to Platform Event:
Set up subscribers for SAP, Azure, and AWS to listen to the Platform Event and process the updates accordingly.
Step-by-Step Implementation:
1. Define the Platform Event
Go to Setup > Platform Events > New Platform Event and define the QuoteUpdateEvent

img84

img86

Create Custom Fields:
QuoteId__c , Name__c, Status__c

img87

2. Publish Platform Event
Create an Apex Trigger on the Quote object to publish the QuoteUpdateEvent whenever a Quote is updated.

img0015

img0016

3. Subscribe to Platform Event
SAP, Azure, and AWS: Each of these systems needs to subscribe to the QuoteUpdateEvent Platform Event to receive updates.

8. Whenever an account record is created, updated, or deleted in Salesforce, the ERP system needs to be updated in real-time. How to achieve this scenario?

We will use Salesforce Change Data Capture (CDC) for real-time updates.
Why Use CDC and Not Platform Event in this case:
CDC

  • CDC is Specifically designed to capture changes in Salesforce data, including creation, updates, and deletions of records without needing custom logic.
  • Retains change events for up to three days, providing a buffer for systems to consume the events.
  • Automatically includes all field changes in the event data, providing a complete picture of what changed.

Platform Event

  • Platform Events are general-purpose event messaging system suitable not tailored specifically for data change tracking.
  • Requires custom logic to capture changes and publish events, adding complexity.
  • Typically designed for immediate consumption and may not retain events as long as CDC.

Step-by-Step Implementation:
1. Enable Change Data Capture (CDC) in Salesforce

  • Go to Setup in Salesforce.
  • In the Quick Find box, type “Change Data Capture” and select it.
  • Select the Account object and enable CDC for this object.

img90

2. Subscribe to the Change Data Capture (CDC) Events in the ERP System

  • Develop a service in the ERP system that listens for CDC events from Salesforce. It is an option to use the CometD library to subscribe to the CDC events.

9. Your company uses an external service to verify customer email addresses. When a new Account record is created in Salesforce, you need to automatically verify the email address using this external service. The verification process involves making a callout to the external service's API, sending the account's email address, and receiving the verification status and quality score. How to achieve this scenario?

To achieve this, we will use Salesforce Flow to make an HTTP callout to the external service’s API whenever a new Account record is created.
The Flow will send the account’s email address to the external service, receive the verification response, and update the Account record with the verification status.

Step by Step Implementation

1: Create a Permission Set

This will allow users to make HTTP callout from Salesforce.
1. Go to Setup:
2. Enter “Permission Sets” in the Quick Find box and select it.
3 Name it HTTP Callout Flow
5. Click “Save”.

img93

2. Add a user to the Permission Set:
Click “Manage Assignments”.
Click “Add Assignments”.
Select your user and click “Assign”.

3: Create an External Credential
1. Go to Setup:
Enter “External Credentials” in the Quick Find box and select it.
2. Click “New”.
3. Fill in the details like Label, API Name, Authentication Protocol as Custom (for free API without client or secret key)
4. Click “Save”.

img95

4.Create a Named Credential
1. Go to Setup:
Enter “Named Credentials” in the Quick Find box and select it.
2. Click “New Named Credential”.
3. Fill in the details like Label, Name, URL. Enter the URL of the external service’s API (https://api.abstractapi.com/)

img96

img98

External Credential: Select the External Credential created earlier

img99

5. Assign the Named Credential to the Permission Set
1. Go to Setup:
Enter “Permission Sets” in the Quick Find box and select the HTTP Callout Flow Permission Set.
2. Click “External Credential Principal Access”.
3. Click “Edit”.
4. Select the External Credential and click “Save”.

6. Create a Screen Flow

img100

In the Flow Builder, click the “+” icon to add an element.

Select “Action”.

img102

In the Action search box, type “HTTP Callout” and select “Create HTTP Callout”.

img103

7. Configure the HTTP Callout
External Service Name, Named Credential

img105

HTTP Method: GET
URL Path: /v1/email/validate
Query Parameters:
– api_key (set to the API key obtained from the external service)
– email (set to the Account’s email field)

img106

img108

8. Provide Sample Response:
Copy the sample response from the external service’s API documentation. and paste it into the “Sample Response” field and click “Review”.

img109

img111

7: Add a Decision Element to Check Response Status

img112

8: Add a Screen Element to Display the Response
9: Save and Activate the Flow

img114