Salesforce Data Retrieval
home
Learn how to build a simple HTTP application to query Salesforce in a dynamic way.
Screenshot of the main flow in Anypoint Studio, view full image here
Description
This example application illustrates how to use Mule ESB to build a simple HTTP application to query Salesforce in a dynamic way. After reading this document, creating and running the example in Mule, you should be able to leverage what you have learned to create an HTTP request-response application that is able to retrieve requested data from Salesforce instance based on your criteria.
This example can also be used while configuring any of our Anypoint Salesforce Templates for retrieving all needed Salesforce entity ID's (e.g. selecting User as object, leaving Field empty and querying by 'email')
Example Use Case
In this example, a user makes an HTTP request to the endpoint containing predefined set of parameters that are extracted and used while building a Salesforce query. Afterwards, the application receives the response and provides it to the end user.
Set Up and Run the Example
As with other examples, you can create template applications straight out of the box in Anypoint Studio. You can tweak the configurations of these use case-based examples to create your own customized applications in Mule.
Follow the procedure below to create, then run the Salesforce data retrieval application.
- Create the example application in Anypoint Studio or Standalone.
- Go to Global Elements and open Salesforce Connector element. Fill in your Salesforce credentials including the security token.
- Run the application.
Open your browser and hit http://localhost:8081. The form will be provided to you, containing following values:
- Object - specify Salesforce object type, e.g. User, Account, Contact, etc.
- Field - a valid field name for the given object you need, e.g. Email for Contact. IMPORTANT: Id and Name attributes are retrieved by default, so choosing these fields will result in an invalid query.
- Search Key - a valid field name for the given object you wil use for matching, e.g. Name for Contact.
- Search Value - a value for the Search Key field that will be used for matching, e.g. young for Contact Name. All records that contain the Search Value value as a substring of the given Search Key field value are returned, i.e. contacts with names such as John Young or Michael Young will be returned. The more specific value, the less results you will obtain.
- Click Submit button.
- You will see the retrieved data structure.
- In case of invalid input, the message: Invalid Salesforce query.
If you are unsure about valid object types and their attributes, please visit Salesforce Documentation site - Standard Objects.