Mule-SFDC-cook book

13
Cook Book to create SFDC Configuration Project in Mule 3.6 and Above Using Query Builder. Purpose : This document Helps beginners to connect the Salesforce via Mule SFDC connector by using the new Data Senses Query Language and Query Builder. Pre-requisites: 1. Salesforce Developer Account ( with System Administrator Access) 2. After Successful Login, To Know your profile Go to My profile Logged User Role 3. Note: With System Administrator Access, You can see Reset Security Token option. 4. Go to My settings Personal Reset My Security Token

Transcript of Mule-SFDC-cook book

Cook Book to create SFDC Configuration Project in Mule 3.6 and Above Using Query Builder.

Purpose : This document Helps beginners to connect the Salesforce via Mule SFDC connector by using the new Data Senses Query Language and Query Builder.

Pre-requisites:

1. Salesforce Developer Account ( with System Administrator Access)

2. After Successful Login, To Know your profile Go to My profile Logged User Role3. Note: With System Administrator Access, You can see Reset Security Token option. 4. Go to My settings Personal Reset My Security Token

5. When Reset My Security Token pressed then New security token sent to registered email.

1. Create A Mule project in Anypoint Studio.

2. Create Global configuration for the salesforce connector and HTTP Listener (mule 3.6 and above). Configure Salesforce User ID, Password and the security Token.(Received in email)

3. Test Connection until it gets successful. ( Best practice is to give reference variables rather than hardcoding the values for future changes)

Configure HTTP configuration

Configure Salesforce component : Add the reference to the global SFDC connector.

Click on the Query Builder: Select the Type you trying to build the Query. It enables the fields to be selected.

In addition to the Query fields we can add the filters, Order By, Limit, Direction and offset.

Simple Salesforce configuration

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"

xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.1"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd

http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd

http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd

http://www.mulesoft.org/schema/mule/sfdc http://www.mulesoft.org/schema/mule/sfdc/current/mule-sfdc.xsd

http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">

<sfdc:config name="Salesforce__Basic_authentication" username="[email protected]" password="xxxxxx" securityToken="yq2RUzVxdJsCWV5DFYDgFfjt" doc:name="Salesforce: Basic authentication"/>

<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8065" basePath="sfdcdemo" doc:name="HTTP Listener Configuration"/>

<flow name="sfdc_demoFlow">

<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>

<sfdc:query config-ref="Salesforce__Basic_authentication" query="dsql:SELECT AccountNumber,Id,Name FROM Account ORDER BY AccountNumber ASC LIMIT 5 OFFSET 1" doc:name="Salesforce"/>

<json:object-to-json-transformer doc:name="Object to JSON"/>

</flow>

</mule>

Run Project.

SFDC SOQL Query Result: in Web browser

Thank You

GDS Sashidhar Rao

[email protected]

Twitter: Gdssrao