Generally mastering Integration concepts look hard to many Salesforce Developers. This article will cover all the Interview questions on salesforce integration concepts such as Salesforce Connect, Streaming API, SOAP API, Bulk API, Salesforce 2 Salesforce, Data Replication API, REST API, Concurrent Limit, Outbound Message, Integration basics and Scenario based questions.
If you have any more questions on Integration questions then put it in comment section so I can add that as well.
SALESFORCE CONNECT
Q. How Does Salesforce Connect Work?
Salesforce Connect uses a feature called external objects, which is like custom objects on Salesforce, except that the data lives in another system. An external object definition includes the external connection to the system where the object data is stored. To access external objects, Salesforce Connect uses several authentication settings.
Q. Explain the adaptors Salesforce Connect use?
Salesforce Connect uses a protocol-specific adapter to connect to an external system and access its data. There are three kind of adaptors
Cross-org provides access to data in another Salesforce org via the Salesforce API. With the cross-org adapter, Salesforce Connect uses Lightning Platform REST API to get data from other Salesforce orgs, letting you connect data with point-and-click tools.
OData connects to any system that supports the OData 2.0 or 4.0 protocol (a REST API for data interchange) for valuable business insights from external data sources. Again, using Lightning Platform, Salesforce Connect interacts with external data via external objects, converting interactions into OData queries that contain parameters to filter results.
Apex custom adapter is code written in Salesforce’s Apex language using the Apex Connector Framework to get data from data sources. With Lightning Platform, Salesforce Connect uses the code when you execute specific functions, such as running a report, so you can connect to data sources for deeper insights into your business.
Q. What are Files Connect Adapters?
Several Files Connect adapters are also available:
- Google Drive
- Box
- SharePoint Online
- OneDrive for Business
Q. How to Use Salesforce Connect?
Integrations with large amounts of data you don’t want to copy into your org.
Integrations with small amounts of data that you need to present.
Data for which you require a real-time connection.
Q. What are the Benefits of Salesforce Connect?
- Read/write from anywhere: Salesforce Connect allows you to create, read, update, and delete records in external sources in real-time.
- Custom Adapters for any web API: Developers can connect Salesforce to any web API.
- Connectors: Connect multiple Salesforce orgs across your company.
Q. What’s the Difference Between Salesforce Connect and Lightning Connect?
Lightning Connect is the feature of Salesforce Connect that lets you access data from external sources and compare it with Salesforce data side-by-side.
Q. What are Salesforce Connect Limitations?
- Salesforce Connect limits data sources to connectors with API support.
- Salesforce Connect limits data sources to connectors where developers have written code to connect to those objects.
- Salesforce requires the implementation of a search capability for each external object you search.
- Connections have callout limit, which means Salesforce org might only call a connector 20,000 times per hour
One of the biggest limitation is that external objects require a common key between Salesforce objects and the external system to relate Salesforce native and/or custom objects to the external object.
Q. What is advantage of lightning connect over API?
- Big players like Microsoft, SAP are supporting this out of box.
- Data is not saved in SFDC so you will save cost on space.
- Data will be always real-time.
- You don’t need any development effort to connect SFDC with external applications, Even business users or Admins can use point and click to integrate.
- If you have lightning connect license, you can connect to external system anytime without any code.
Q. An org got to a point, where data usage is over limit. More than 65% of that data is old/disabled data. However, that data should still be available to all users of SF to view (it hold’s historical data). The idea was to take/export/delete all historical data (periodically) and upload it to another server, that can host it, with a SF visual page (or other option) to see the data.
What is the best solution?
External objects allow you to store the data off platform but utilize a special kind of Custom Object to view it.
Track and represent data from sources outside Salesforce by creating external objects. Each external object maps to a table in a data source outside Salesforce, and allows you to set up access to its data from search and custom tabs in Salesforce. Each external object relies on the connection details stored in an external data source definition.
Q. What can I do with an External Object?
Standard and Custom Objects | External Objects | |
Write | X | |
Read | X | X |
REST and SOAP API | X | X (read only) |
Custom Tabs and Details | X | X (read only) |
SOQL | X | X (read only, no aggregation, no tracking) |
Search and SOSL | X | X |
Reports and Analytics | X |
Q. We’re designing a system for a client that involves quite a bit of data. The regular data storage limits in Salesforce will be exceeded by a factor of 10 or more. Which technology is recommended?
One technology that seems like it might be cost effective is to store large static sections of data remotely and access it using External Objects/OData/Lightning Connector
Q. Does oData using lightning connect syncs automatically? If yes then what is the frequency? If no then how the sync happens?
It does not sync automatically. Salesforce Connect only syncs when you ask it to.
Salesforce Connect will re-read the $metadata document over time so you will see Salesforce send GET requests against it periodically (a data type on the Salesforce side could map to a column of many different data types on the OData side, so this confers some flexibility to adapt to minor changes on the remote end). But Salesforce Connect will NEVER alter the External Object metadata or its custom fields automatically.
We’re going to implement lightning connect from Salesforce to our own servers, and are deciding between:
- Implement OData on our servers and set up lightning connect to use OData
- Implement an Apex custom connector and have it talk to our servers via HTTP calls, using whatever protocol we design for ourselves.
Q. We’re going to implement lightning connect from Salesforce to our own servers, so what option we have to choose between:
- Implement OData on our servers and set up lightning connect to use OData
- Implement an Apex custom connector and have it talk to our servers via HTTP calls, using whatever protocol we design for ourselves.
OData is an open data exchange standard. The alternative, using pure Apex Code, is intended to interface with systems that do not understand OData and that you can’t justify writing an adapter for on the far side for whatever reason (e.g. the server is already overloaded, you plan on replacing the software soon, not enough resources, etc). You’ll have a lot less maintenance to do yourself if you go with OData.
However, you can do stuff with your Apex Code, so if you want to pull from multiple discrete resources, or some more complicated logic than what OData allows, that would be a good reason to go with Apex Code. It’s usually just unnecessary in most cases. Just be aware that doing so might also result in slower performance when using these objects.
STREAMING API
Q. What is a platform event?
Platform events are part of Salesforce’s enterprise messaging platform. The platform provides an event-driven messaging architecture to enable apps to communicate inside and outside of Salesforce. Use platform events to deliver secure and scalable custom notifications within Salesforce or from external sources.
Example: A user has salesforce and twitter account which are linked to each other. When a user change address in twitter, his address should also get changed in salesforce. For doing so we will use platform events to provide notification for changing the address.
Publishing platform event:
We can publish the platform events in 3 ways:
- Publish Events Messaging using APEX.
- Publish Events Messaging using Declarative tools (Process Builder or Cloud Flow Designer Tool / Visual Work flow).
Q. Explain Event-Driven software architecture?
Event
A change in state that is meaningful in a business process. For example, placement of a purchase order is a meaningful event because the order fulfillment center expects to receive a notification before processing an order.
Event message
A message that contains data about the event. Also known as an event notification. For example, an event message can be a notification about an order placement containing information about the order.
Event producer
The publisher of an event message.
Event channel
A stream of events on which an event producer sends event messages and event consumers read those messages. For platform events, the channel is for a single platform event and groups all event messages for that platform event.
Event consumer
A subscriber to a channel that receives messages from the channel. For example, an order fulfillment app that is notified of new orders.
Event bus
A communication and storage service that enables event streaming using the publish-subscribe model. The event bus enables the retrieval of stored event messages at any time during the retention window.
Systems in request-response communication models make a request to a web service or database to obtain information about a certain state. The sender of the request establishes a connection to the service and depends on the availability of the service.
Q. Explain The role of Event Bus in platform event?
Platform event messages are published to the event bus, where they are stored temporarily. You can retrieve stored event messages from the event bus using a CometD (Streaming API) client. Each event message contains the ReplayId field, which identifies the event in the stream and enables replaying the stream after a specific event.
Q. What are Custom Platform Events?
Use custom platform events to publish and process custom notifications. For example, publish custom platform events to send order information to an order fulfillment service. Or publish custom platform events to send printer ink information that is processed by a service app.
You define a custom platform event in Salesforce in the same way that you define a custom object. Create a platform event definition by giving it a name and adding custom fields.
Q. What are Standard Platform Events?
Salesforce provides events with predefined fields, called standard platform events. An example of a standard platform event is AssetTokenEvent, which monitors OAuth 2.0 authentication activity. Another example is BatchApexErrorEvent, which reports errors encountered in batch Apex jobs.
Salesforce publishes standard platform events in response to an action that occurred in the app or errors in batch Apex jobs. You can subscribe to a standard platform event stream using the subscription mechanism that the event supports.
Q. What are considerations for Platform Events ?
- Unlike custom or standard objects, you can’t update or delete event records.
- You also can’t view event records in the Salesforce user interface.
- Platform events don’t have page layouts.
- When you delete a platform event definition, it’s permanently deleted.
- You can set read and create permissions for platform events. Grant permissions to users in profiles or in permission sets.
Q. What is Event Retention time in the Event Bus?
- High-volume platform event messages are stored for 72 hours (3 days).
- Standard-volume platform event messages are stored for 24 hours (1 day).
- You can retrieve past event messages when using CometD clients to subscribe to a channel.
Q. Explain Order of platform Events?
If you publish multiple events in one publish call, the order of events in a batch is guaranteed for that publish request. So the order of event messages that are stored in the event bus and delivered to subscribers matches the order of events that are passed in the call.
You can publish multiple events in several ways, including the Apex EventBus.publish method or the REST API composite resource. For events published across different requests, the order of events is not guaranteed because publish requests can be processed by different Salesforce application servers. As a result, a later request could be processed faster than an earlier request.
Salesforce assigns a replay ID value to a received platform event message and persists it in the event bus. Subscribers receive platform event messages from the event bus in the order of the replay ID.
Q. Explain Publish Behavior of platform event?
- Publish After Commit to have the event message published only after a transaction commits successfully. Select this option if subscribers rely on data that the publishing transaction commits.
- Publish Immediately to have the event message published when the publish call executes. Select this option if you want the event message to be published regardless of whether the transaction succeeds. Also choose this option if the publisher and subscribers are independent, and subscribers don’t rely on data committed by the publisher.
Q. Explain ReplayId System Field?
Each event message is assigned an ID contained in the ReplayId field. The ReplayId field value, which is populated by the system when the event is delivered to subscribers, refers to the position of the event in the event stream. Replay ID values are not guaranteed to be contiguous for consecutive events.
Q. What is Change Data Capture?
Change Data Capture event, or change event, is a notification that Salesforce sends when a change to a Salesforce record occurs as part of a create, update, delete, or undelete operation. The notification includes all new and changed fields, and header fields that contain information about the change.
Use change events to:
- Receive notifications of Salesforce record changes, including create, update, delete, and undelete operations.
- Capture field changes for all records.
- Get broad access to all data regardless of sharing rules.
- Get information about the change in the event header, such as the origin of the change, which allows ignoring changes that your client generates.
- Perform data updates using transaction boundaries.
- Use a versioned event schema.
- Subscribe to mass changes in a scalable way.
Q. Is it possible to Publish and subscribe events between two separate orgs natively?
Subscribing to events from another org is not natively supported on the platform right now.
Let’s say org A publishes a Customer_Event__e . So it would not be possible for org B to subscribe to events on org A.
Q. There is a use case to sync account and contact to external system. Can platform events be used to update external systems if Accounts/Contacts in our org is created or updated?
Platform events can be used to “notify” an external system that an Account or Contact has been updated. Recognize that a platform event sends a push notification via the streaming API. There’s no guarantee the subscriber will receive it and it won’t provide the subscriber with what they might need to authenticate to get the updated record in the same way outbound messaging does.
Change Data Capture would work for this situation. The updates would occur Asynchronously and be processed as time is available on the server. It Receive near-real-time changes of Salesforce records, and synchronize corresponding records in an external data store. Change Data Capture publishes change events, which represent changes to Salesforce records. Changes include creation of a new record, updates to an existing record, deletion of a record, and undeletion of a record.
Q. How to generate debug logs for platform events?
Debug logs for platform event triggers are created by a process called “Automated Process” and are separate from their corresponding Apex code logs. The debug logs aren’t available in the Developer Console’s Log tab. One exception is Apex tests, which include debug logging for event triggers in the same test execution log. To collect platform event trigger logs, add a trace flag entry for the Automated Process entity in Setup.
Q. Can you query platform event?
it’s not supported and meaningful to query events using SOQL
Platform events form an ordered time stream. Each event has a specific “replay ID”, and each event’s replay ID is higher than the previous event’s. They’re guaranteed to be delivered in a specific order to clients that are watching the event stream, such as Platform Event triggers and external subscribers.
There is a replay mechanism whereby clients that “missed” part of the stream can supply the last replay ID they received and have all of the event between then and the current moment resent to them for processing (again, in order).
Events are intended to be ephemeral ordered messages, not random-access data storage. An event would be something like “Object X changed!”, where the underlying data store is Object X. You can query that object, but it wouldn’t make sense to query the event itself. An individual event may or may not contain enough information to carry meaning outside its position in the timestream and the state of the object at that time.
Q. Difference between SObject and Platform Events?
SObjects__c | Platform_Events__e |
DMLs (Insert, Update, Delete) | Publish (Insert only) |
SOQL | Streaming API |
Triggers | Subscribers |
Parallel context execution | Guaranteed order of execution |
Q. Can apex trigger on platform events?
Yes
SOAP API
Q. Step by step process of integration of salesforce with salesforce using SOAP?
First, log into the Salesforce (Destination system) that you want to receive the data from.
You should create an integration only user. This allows you to control security (or open up access) for the middleware integration. Set the integration user’s profile settings so that its password never expires, but it is not absolutely necessary.
Also, Expose Webservice as a SOAP API.
global class FetchAccount1
{
webservice static Account createAccount(String Name) {
Account acct = new Account();
acct.Name = Name;
insert acct;
}
}
Above code insert account and will return the inserted account.
Second, you have two different WSDL’s you can choose from in Salesforce. Either the partner WSDL or the enterprise WSDL.
The partner WSDL is loosely typed, meaning that it is allows you to dynamically specify elements and attributes to an extent.
The enterprise WSDL is strongly typed. The downside of the enterprise WSDL is that any time your Salesforce schema changes, whether it’s objects or fields, you have to refresh and re-import the WSDL into your middleware.
Third is planning out the various calls you will need to make (When to query, when to insert or upsert, delete etc).
As part of the calls to SFDC, start mapping out your business process in the middleware layer. When you insert records, when you update, how you handle errors, the frequency of the integration (is it a nightly integration, immediate, hourly, whatever).
Fourth, is testing integration. Pick up SoapUI. This plugin helps you test the SOAP callouts to Salesforce before you hook them into the integration.
Fifth, Log into another Salesforce (Source system) that you are going to send the data and follow the below steps
- Under Build section, navigate to Develop [Symbol] Apex Classes, click Generate from WSDL button and select the Partner WSDL file (i.e. partner.xml) that you created in the Step 3. Now, click Parse WSDL button
Sixth, Create Remote site settings for the destination Org in the Source Org
Q. What are considerations for Using the webservice Keyword?
- We can’t use the webservice keyword to define a class or an inner class method, interface, or to define an interface’s methods and variables.
- We can use to define top-level methods and outer class method
Q. What is WSDL?
A WSDL is an XML Document which contains a standardized description of how to communicate using webservice.
Q.What are the different type of WSDL’S?
Enterprise WSDL
Partner WSDL
Apex WSDL
Metadata WSDL
Tooling WSDL
Delegated Authentication WSDL
Q. Difference between Enterprise WSDL and Partner WSDL?
Ans:
Enterprise WSDL:
It is used for building client applications for a single salesforce organization.
Customers who use enterprise WSDL document must download and re-consume it whenever their organization makes a change to its custom objects or fields or whenever they want to use a different version of the API.
Partner WSDL:
It is used for building client applications for multiple organizations.
The partner WSDL documentation only needs to be downloaded consumed once per version of the API.
Q. What is SoapUI ?
soapUI is a free open-source desktop application targeted for developers and testers.
−RESTful Web Services (used by the Bulk API)
−SOAP-based Web Services
With soapUI you can Inspect, invoke, and develop Web Services and Perform functional, load, and compliance testing of Web Services.
Q: What is Limitations of WSDL file?
File must be in .WSDL extension.
Multiple port types and binding will not be allowed
Import and Inheritance operations are not supported
Q. We are integrating SFDC with External system, where external system will invoke our webservice class and salesforce will accept the request using SOAP API.
Here external system will send us information and SFDC has to capture that request and parse it, to create case in the SFDC and send back the response to external system.
Who will generate WSDL and how to do it?
Salesforce Accepts the request – Provides WSDL
External system – Consumer of WSDL
If you have defined your Apex class as global and your method as a webservice, then in Salesforce, you should be able to generate the WSDL.
global with sharing class WSClass {
webservice static boolean wsMethod() {
return true;
}
}
Steps to follow :
Steps you are supposed to follow
- Import Partner WSDL
- Import WSDL for the class
- Generate stub classes for both the WSDL files. Include them in your source code package.
- Invoke Login service from the partner port stub class. You’ve to pass Username and password if you’ve listed your client IP in Salesforce, else you need to pass Username and “password+Security token” in password field.
- From the Response received get the Session ID.
- Invoke your Case class web service port from the stub, supply values you need to pass to create case along with the Session Id.
- Get the response . eg: Case Id/Case Number.
- Log out using Logout service in the partner port stub class, supplying the session ID.
Q. A company processes Orders within their Salesforce instance. When an Order’s status changes to ‘Paid’ it must notify the company’s order management system (OMS). The OMS exposes SOAP web service endpoints to listen for when to retrieve the data from Salesforce.
What is the optimal method to implement this?
Generate the Enterprise WSDL and use it to make a callout to the OM
BULK API
Q. What is difference between SOAP and Bulk API?
SOAP is synchronous and BULK is asynchronous.
Synchronous means that the batches are updated one at a time, in order of when the job was queued and you have to finish one before you can start the next. Asynchronous can run in parallel and doesn’t require previous entries to finish before starting the next batch.
Q. When to Use Bulk API?
Bulk API is based on REST principles and is optimized for loading or deleting large sets of data. You can use it to query, queryAll, insert, update, upsert, or delete many records asynchronously by submitting batches. Salesforce processes batches in the background.
The easiest way to use Bulk API is to enable it for processing records in Data Loader using CSV files. Using Data Loader avoids the need to write your own client application.
Q. How Bulk API Works?
Processing data typically consists of the following steps.
- Create a new job that specifies the object and action.
- Send data to the server in a number of batches.
- Once all data has been submitted, close the job. Once closed, no more batches can be sent as part of the job.
- Check status of all batches at a reasonable interval. Each status check returns the state of each batch.
- When all batches have either completed or failed, retrieve the result for each batch.
- Match the result sets with the original data set to determine which records failed and succeeded, and take appropriate action.
Q. Explain Parallel Vs Serial Mode in Bulk API?
We can process record using Bulk API. By default, Bulk API records are process using parallel mode, where multiple records are process in multiple batches. It might throw record lock or record lookup issue. Record lookup issue is where one records is being processed in one batch and referenced record is being processed in other batch, so it will create issue in processing. To avoid that situation we can go with serial mode or we can organize related records in same batch.
Serial mode processing is only possible in Bulk API V1.0. Bulk API V2.0 only process record in parallel mode.
SALESFORCE 2 SALESFORCE
Q. What is Salesforce to Salesforce is a feature that allows you to share data with another salesforce.com Organization?
Salesforce to Salesforce is a feature that allows you to share data with another salesforce.com Organization.
Q. How to enable Salesforce to Salesforce (S2S)?
- Enter “Salesforce to Salesforce Settings” in Salesforce’s Quick Find box.
- Select “Salesforce to Salesforce Settings.”
- Click “Edit.”
- Select “Enable.”
- Click “Save.”
Note that S2S needs to be enabled by both organizations before you can start sharing data.Enabling S2S will make the connection’s tab available in Salesforce.
Q. Steps to do for S2S Connect?
STEP 1) Enabling Salesforce to Salesforce
Step 2) Connection Setup
To setup connection you need to open “Connection” Tab. Then Click on New Tab.
Step 3) Publishing Objects
Now we need to publish or subscribe the standard or custom object. To publish the object you need to go to first Org and click on “Publish/Unpublish” button.
Then select the object and click on save.
Step 4) Subscribing Objects
Now got back to receiving org and click on “Subscribed Objects” related list.
Step 4) Subscribing Objects
Now got back to receiving org and click on “Subscribed Objects” related list.
Then map the object.
Now we need to map the field. Go to “Subscribed Object” related list and select object and map field.
Q. Give Pros and Cons of Salesforce2Salesforce Integration?
Pros:
- Uses pub/sub model, easy to grok and explain to customer
- All background S2S operations are event-driven and asynchronous
- Solution handover is assisted because you can point to Salesforce docs
- S2S runs under its own integration user which offers some auditability
- Automatically logs local/remote schema changes and record sync failures
- For every record that doesn’t sync, admin receives an email with details
Cons:
- Not quite real time, 1 minute typical
- Often inappropriate for heavily customized orgs
- Unrealistic customer expectations, risk behind apparent simplicity
- There is no metadata. No source control. No change sets.
Q. What makes S2S easy?
- Fast time to value, stand up working customer demo very quickly
- If you spend 1 day playing with S2S you will find its constraints well defined
Q. What makes S2S hard?
Bidirectional sync is fussy, each record must originate in one system
Q. What are limitations of S2S integration?
- Only certain objects (and custom objects)
- Any field change syncs the whole record
- Loops occur if the same field triggers updates on both sides of S2S.
- There are undocumented rate limits like REQUEST_LIMIT_EXCEEDED**
DATA REPLICATION API
Q. What is Data Replication API and Apex Scheduler?
Salesforce Replication API (which is a SOAP API) and its Apex equivalents. The Database.getUpdated method can used to obtain a list of records created within a certain time frame.
Returns the list of individual records that have been updated for an sObject type within the specified start and end dates and times.
As long as you are not under pressure to make the synchronize real-time, you could use this API, to schedule an Apex job every day or every hour if needed. Then leverage Batch Apex to kick off a job to process the records, this will scale very well as it allows you to chunk the governor limits, such as those around the number of HTTP callouts (10 per Apex execution scope) that can be made per request or scope in Batch Apex terms. You can also better manage synchronization errors, by collecting errors and emitting a report or log records at the end of the job.
Q. My organization has a requirement that if anything is updated/inserted in our web application that it should be automatically be updated in SFDC and vice versa.
There are 1000 of users in our website and they have their account in salesforce too. Now to sync the data between these two some real time automatic updates are required. Also whenever a new user logs in we should not have to do any coding again.
-How can we synchronize their data between sfdc and our application? -Can we show the real time automatic updates?
Option1 – Salesforce REST and SOAP API
Salesforce REST and SOAP API’s provide a full CRUD based API to the data in Salesforce, such that you can use these API’s to callout from the appropriate place in your code.
Option 2 -Streaming API
The Salesforce Streaming API is not ideal for your requirements since Salesforce cannot guarantee delivery.
Streaming API doesn’t guarantee durability and reliable delivery of notifications. Streaming servers don’t maintain any client state and don’t keep track of what’s delivered. The client may not receive messages for a variety of reasons
Option 3 – Outbound Message
Outbound Messages are linked with the Workflow engine, which only covers insert and update, not delete. They are more real time, though some conditions exist where messages can be dropped.
Option 4- Replication API – Best Option
The most reliable way is the Replication API. Though this is not real time however, though it does give access to records created, updated and deleted within the last polled time frame. You could run a service in your web application to periodically make these replication API calls.
The API supports data replication, which allows you to store and maintain a local, separate copy of your organization’s pertinent Salesforce data for specialized uses, such as data warehousing, data mining, custom reporting, analytics, and integration with other applications. Data replication provides you with local control and the ability to run large or ad hoc analytical queries across the entire data set without transmitting all that data across the network.
Q. Is the replication API method good for multiple users trying to sync the data simultaneously?
The API will only return records that are visible to the user the API is logged in as, so make sure your API user has enough privileges to see the records you want to replication.
Q. There are 1000 of users in their website and they have their account in salesforce too. Now to sync the data between these two some real time automatic updates are required.
How we can synchronize the data between sfdc and web application?
The most reliable way which is actually designed for this use case is the Replication API. Though this is not real time however, though it does give access to records created, updated and deleted within the last polled time frame. We could run a service in the web application to periodically make these replication API calls.
Q. When an Account is created in Salesforce I need to call a SAP webservice and create a customer in SAP.
Call the SAP webservice from the Account trigger by calling a future method
This brings with it new vulnerabilities to consider, especially since @future methods are not easily tracked, making error handling and recovery quite critical here. Also when your performing large data loads there is a also a limit of 10 per Apex Trigger context.
CONCURRENT LIMIT
Q. What are the Concurrent limits in Salesforce?
If multiple requests are running more than the specified time interval then all those request will be treated under Concurrent limits. Salesforce has broadly divided these limits into 2 categories
- Concurrent API Request limit
- Concurrent Callout Request/Apex limit
Q. Explain about Concurrent API Request limit?
If salesforce receiving any incoming API request from the external systems and all those api requests which are taking more than 20 sec will be counted under these API Request limits.
At any given point of time salesforce allows only 25 requests running more than 20 sec is allowed. If 25 requests are already took 20 sec and meanwhile if you receive 26th request and if this 26th request is also crossing the 20 sec then system will throws an error an terminates this 26th request automatically.
In case if 26th request is finished it’s execution within 20 sec then no error will be thrown.
Q. How can we avoid Concurrent Callout Request/Apex limits?
Yes,we can avoid these errors just moving all these synchronous long running request into asynchronous long running request by using the Continuous Integration.
REST API
Q. Write Rest syntax?
Rest Callout
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint(‘https://test.com’);
request.setMethod(‘GET’);
HttpResponse response = http.send(request);
// If the request is successful, parse the JSON response.
if (response.getStatusCode() == 200) {
}
}
Expose a class as REST service
@RestResource(urlMapping=‘/Account/*’)
global with sharing class MyRestResource {
@HttpGet
global static Account getRecord() {
// Add your code
}
}
Q. Test class for REST and SOAP?
Create a Mock Class
The first step is to create a mock class for API callout. The first step is to create a class that implement the HttpCalloutMock interface. The mock class is nothing but a class that will generate a fake response for our API callout in the test class. As, we don’t need to hit the actual API while testing, we should have a fake response that will be returned when a callout is performed.
The mock class is also a test class with @isTest annotation that implements HTTPCalloutMock interface.
This interface consist of a single method which accepts an instance of HttpRequest class as a parameter and return an instance of HttpResponse which we’ll construct inside the method itself.
Q. Give Syntax of all rest methods?
Annotation Action Details
@HttpGet Read Reads or retrieves records.
@HttpPost Create Creates records.
@HttpDelete Delete Deletes records.
@HttpPut Upsert Typically used to update existing records or create records.
@HttpPatch Update Typically used to update fields in existing records.
Q. Difference between SOAP n REST?
SOAP | REST |
|
|
|
|
|
|
|
|
|
{“city”:”Mumbai”,”state”:”Maharastra”} |
|
|
Q. How can you expose an apex class as a REST web service in salesforce?
An apex class can be exposed as REST web service by using keyword ‘@RestResource’
Q.What is the use of Chatter REST API?
The Chatter API (also called Chatter REST API) lets you access Chatter information via an optimized REST-based API accessible from any platform. Developers can now build social applications for mobile devices, or highly interactive websites, quickly and efficiently.
Q. What is the difference between REST API and APEX REST API?
Similar to Standard object/fields and Custom object/fields in Salesforce,these APIs are also comes under this Standard APIs and Custom APIs.
REST API:
This API provided by Salesforce with pre-built set of services which will be running on REST protocol to interact with Salesforce ecosystem. This provides powerful and convenient way to interact with Salesforce system.
This is very easy for integration and it best suits for applications which are running on mobile applications and web projects. The detailed document can be found here.
APEX REST API:
If you have an use case where you want to share some of your salesforce org data with external systems/you want to update salesforce data basis on the external system request with REST protocol and your use case is not available in standard REST API provided by salesforce.
In these scenarios you will create an apex class which can handle all your scenarios and shares/update the necessary data with external systems at the same time running these apex classes on REST protocol. The entire class or methods which has written then exposed with external systems using this APEX REST API.
Q. What are the Authentication mechanisms used by Apex REST API?
- OAuth 2.0
- Session Id
Q. What is JSON?
JSON stands for JavaScript Object Notation. JSON is light weighted than XML
INTEGRATION BASICS
Q. Can Named Credentials be used to support token based authentication?
Yes, that’s one of the primary benefits of using Named Credentials.
Q. What are outbound messages?
Outbound messages are linked with the Workflow engine, which only covers insert and update, not delete. They are more real time, though some conditions exist where messages can be dropped.
Q. We need to have the ability to make more than 2999 callouts to a REST service. Currently, we are getting a raised exception when the number of callouts is more than current limit for callouts of 100
Thus, is there a solution for doing async REST callouts within Apex class to support the large amount required to support our requirement?
Create a batchable class,and do as many callouts as you need. The 100 callout limit applies only to a single transaction, but Batchable classes can create millions of callouts.
Q. What are limitation of outbound messages?
We have outbound messages as one of the Actions for workflows. This works if other party implements the WSDL that is generated once Outbound messaging is defined with appropriate end point .
Q. What is the best approach of making callout to external web services?
Future method invoked through triggers allowed to do apex callouts and invoke external web service provided the future method is annotated with @future(callout=true).This provides lot of flexibility and one of the best approaches
Q. Can we make callout directly from trigger?
No we cannot. Callout is a Asynchronous process where as Trigger is Dynamic / Synchronous. Callouts would hold up the database transaction until the callout completed, which can be up to 120 seconds from a limits perspective. This could cause significant contention with other transactions and impact performance. That means it is not directly possible to do a web service callout from a trigger. But using @Future annotation we can convert the Trigger into a Asynchronous Class and we can use a Callout method.
Q. How to use HTTP Callouts in batch class?
To use HTTP Callouts in batch class we need to use Database.allowcallouts in interface.
Q. How many callouts to external service can be made in a single apex transaction?
A total of 10 callouts are allowed in a single apex transaction.
Q. What is the maximum allowed time limit while making a callout to external service in apex?
Ans – maximum of 120 second time limit is enforced while making callout to external service
Q. What is the default timeout period while calling webservice from Apex.
10 sec.
Q. Can we define custom time out for each call out?
A custom time can be defined for each callout.
the minimum time is 1 millisecond and maximum is 120,000 milli seconds.
Q. How to increase timeout while calling web service from Apex ?
docSample.DocSamplePort stub = new docSample.DocSamplePort();
Q.How many types of API’s avaliable in salesforce?
- REST API
- SOAP API
- Bulk API
- Streaming API
- Metadata API
- Chatter REST API
- User Interface API
- Analytics REST API
- Apex REST API
- Apex SOAP API
- Tooling API
Q.What is Remote Site Setting and What is the action of it?
In Remote site settings we will add the external system domain address where Salesforce is going to make a callout for some information.
As soon as you added the domain name to the remote site setting it internally informs the Salesforce ecosystems these are my trusted domain names so you can allow call out to these services from Salesforce.
Q. What happens if domain is not added while making a callout from Salesforce to External System?
It’s mandatory to add the external system domain names in remote site setting while salesforce making any callout to these services. If not added then salesforce treats all these external systems domain names as not trusted domains .So,callout will not triggered from the salesforce.
Q.How will Salesforce authenticates every incoming request?
Every third party request coming into Salesforce will be authenticated by OAuth 2.0,using the OAuth 2.0 third party systems will get the access token first from the salesforce authorization server ,then the access token will be passed as part of every request.
So,Salesforce check whether this token is valid or not,expired or not,if everything if fine then only salesforce processes this request otherwise it will throws an error.
Q. Difference between named credentials and remote site setting?
Remote Site Setting | Named Credential |
Specifies the URL of callout endpoint | Specifies the URL and its required authentication in a single definition |
Management of authentication needs to manually done by Apex developer where required | Salesforce manages all the authentication |
Maintenance is difficult if any change occurs in future | Maintenance is easy as it is single point of change |
Implementation varied based on the authentication required for each remote site setting | Irrespective of the authentication selected implementation remains the same |
Q. What is benefit of named credentials?
Benefits of using Named Credentials:
- A named credential specifies the URL of a callout endpoint and its required authentication parameters in one definition.
- You can skip remote site settings, which are otherwise required for callouts to external sites, for the site defined in the named credential.
- Using Named Credential, we can make a call out to an external system without supplying username or Password in the code.
- By separating the endpoint URL and authentication from the callout definition, named credentials make callouts easier to maintain. For example, if an endpoint URL changes, you update only the named credential. All callouts that reference the named credential simply continue to work.
- It supports two types of authentication protocols for now: Basic Authentication(Password authentication) or OAuth
Q. What is connected App?
A connected app is a framework that enables an external application to integrate with Salesforce using APIs and standard protocols, such as SAML, OAuth, and OpenID Connect. Connected apps use these protocols to authenticate, authorize, and provide single sign-on (SSO) for external apps. The external apps that are integrated with Salesforce can run on the customer success platform, other platforms, devices, or SaaS subscriptions. For example, when you log in to your Salesforce mobile app and see your data from your Salesforce org, you’re using a connected app.
Good content.
Q. How many callouts to external service can be made in a single apex transaction?
A total of 10 callouts are allowed in a single apex transaction.
It should be 100 isn’t ?