While a dedicated Salesforce-related action and connector are already on our to-do list and planned for release in v5 later this year, you can already start querying Salesforce using existing EasyMorph tools! In this article, I will explain how to create and configure a connection to Salesforce. Also, a working sample project is attached.
Creating Connected App in Salesforce
First, you need to create a new Connected App. Note that using Web API in Salesforce requires you to have an Enterprise or Unlimited account (as of January 2021).
To create a Connected App, you should go to Platform Tools â Apps â App Manager and then pick the âNew Connected Appâ button thatâs located in the top-right corner of the app manager page.
Fill in required fields, such as âConnected app nameâ, âAPI name,â and âContact emailâ â fill them as you like, then tick the âEnable OAuth settingsâ checkbox.
In âCallback URLâ below, enter the local address that Easymorph would use to receive authorization tokens. This should be something like âhttp://localhost:XXXX/authorizeâ, where XXXX is a free port of a PC that your copy of Easymorph runs on. Pick any number you like â for example, âhttp://localhost:7890/authorizeâ should work fine â but remember to enter exactly this URI in the âRedirect URIâ box during the connector configuration step. Salesforce checks this URI to match during the OAuth process.
In âSelected OAuth scopes,â pick âAccess and manage your data (api)â and âPerform requests on your behalf at any time (refresh_token, offline_access)â. These scopes too have to be entered during the connector configuration step.
Generally, your OAuth settings box should look like this:
After you are done with filling in the rest of the description, click the âSaveâ button at the bottom of the page and wait for approximately 10 to 20 minutes for Salesforce to recognize your newly created application.
Configuring EasyMorph Web location connector
In Easymorph, go to âConnector Managerâ, pick âNew Connectorâ â âWeb locationâ, then click âPresetsâ and pick âSalesforceâ. That should fill all standard fields, including permission scopes and authorization/token/redirect URLs
Now you have to fill two remaining fields (Base URL in general Connection tab and Client ID in OAuth configuration window), and youâre good to go.
Click the âConfigureâ button next to the Authentication combobox (that should display âOAuthâ now). OAuth configuration window should appear. Open the âSettingsâ tab and fill in the Client ID field using values from Salesforce Connected App âConsumer keyâ configuration field. To find it, go to your Salesforce account, Apps â App Manager, find your newly created Connected App and click the dropdown icon situated in the rightmost column, then choose the âViewâ option. On a page that appears, you should see your Consumer Key in the API section:
Now you have everything that is needed to complete the authentication step but to be able to run queries against Salesforce you have to enter one more value, thatâs a âBase URLâ in the Web Location connector âConnectionâ tab.
For Salesforce, this URL is a combination of your assigned instance ID and Web API URL and should look like
In this example, EU40 is an instance name and the rest is a base URL for running SOQL queries. The instance name is provided by Salesforce in a custom âinstance_urlâ claim during the OAuth flow process and as such is not recognized by EasyMorph for now, but it can be guessed.
First, you can go to your Salesforce account, Settings â Company Settings â Company Information and there you have the âOrganization detailâ block and âInstanceâ field.
Second, you can copy the first part of the URL while you are at your Salesforce account page. Enter copied text as an instance, postfixed with â.myâ part, see below:
Copy first subdomain from URL (thatâs your account name)
And paste it like this, appending â.my.salesforce.com/services/data/v50.0â afterwards
Now you should be able to press the âAuthorizeâ button in the connector window and start querying your data!
Querying Salesforce
The easiest way to execute SOQL Query is (if you have less than 2000 resulting rows) to use the âImport from Web APIâ action. Just add this action, select your newly created Salesforce connector and add âqâ to the URL parameters block. Thatâs where you can enter queries in SOQL:
Apply deduplication/cleanup actions to your taste and you should be able to see your data:
However, when the expected row count for your query exceeds 2000 (default Salesforce page size), such a simple approach would not suffice, and you will need to deal with paging, which is implemented in Salesforce via server-side cursor that has to be consecutively queried using ânextRecordsUrlâ response field.
Handling server-side cursors can be done by the âIterate Web requestâ action and is a little out of the scope of this article, but for those who need such functionality right now, there is an example project with a ready module in the attachment:
Salesforce Query Example.morph (8.4 KB)
Note that the attached example does not include an embedded Salesforce connector, and you have to create your own and use it instead of the âsalesforce-connectorâ placeholder in the âSf Queryâ module
The project allows executing any SOQL (Salesforce Object Query Language) query specified as a project parameter and return the result. Even if you donât want to get into details on how the project works, you can use it as a âblack boxâ. Just configure a Salesforce connector, then run this project with a SOQL query from other projects in order to pull data from Salesforce.