Connecting Salesforce With MuleSoft
Learn how you can fetch and view all chosen accounts objects from Salesforce in MuleSoft with this quick integration tutorial.
Join the DZone community and get the full member experience.
Join For FreeAs most of you know, Salesforce is a leader in CRM (Customer Relationship Management). Let's see how to connect to Salesforce from MuleSoft.
Use Case
To fetch all accounts objects from Salesforce in MuleSoft.
Steps
Create a new project in Mulesoft (File->New->Mule Project) and give the project a name. Click Finish.
Create an account on developers.salesforce.com. After sign-in, in the home page top right corner under your name, go to My Settings.
Go to Personal Tab and select "Reset My Security Token." You will get the security token in the registered mail id.
In Anypoint Studio, drag the HTTP component and configure the connector configuration. Select the host and enter the port number. Click OK.
Drag the Salesforce connector from the Mule Palette. Add a connector configuration and select Salesforce: Basic Authentication.
Provide your username, password, and security token. Click on Validate Configuration and check whether the test connection is successful.
Select the "Query" operation andset the Language as "DataSense Query Language." Click on Query Builder. Select Accounts Object and the necessary columns (in my case: AccountNumber, BillingCity, BillingCountry, BillingStreet, and Description) and click OK. The query is automatically generated, as below:
The outcome of the query operation in Salesforce is a consumerIterator object. In order to view the output in a readable form (like JSON), use the object to JSON transformer.
Save the project and right click the project folder in the project explorer->Run As->Mule Application.
In the console, the status of the application can be seen as "DEPLOYED." Go to the browser (or Postman) and hit the endpoint (http://localhost:8081). The selected fields from the Account object are displayed.
Opinions expressed by DZone contributors are their own.
Comments