Salesforce Account Creation in Mule | Salesforce Connector in Mule




Salesforce Account Creation in Mule | Salesforce Connector in Mule

We can create salesforce account from mule application.Mule has marvelous support for salesforce crm.

flow of account creation in salesforce : 


salesforce connector configuration : 


connector configuration : 


Transform Message configuration : 

for input metadata input.json is used.


input.json is stored in src/main/resources

input.json  :

{
  "Name": "Donald Cook",
  "BillingStreet": "Baker Street",
  "BillingCity": "Mumbai",
  "BillingState": "Maharashtra",
  "BillingCountry": "India",
  "BillingPostalCode": "400710"
}


output metadata is automatically populated when salesforce connector configuration is done.


Connect input meta data with output meta data.



URL : http://localhost:8085/api/salesforce
Method : POST


Input : 


Output : 



XML project code : 


<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc" xmlns:servlet="http://www.mulesoft.org/schema/mule/servlet" xmlns:http="http://www.mulesoft.org/schema/mule/http" 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" 
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/servlet http://www.mulesoft.org/schema/mule/servlet/current/mule-servlet.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/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
    <sfdc:cached-basic-config name="Salesforce__Basic_Authentication" username="***********" password="************" securityToken="*************" doc:name="Salesforce: Basic Authentication"/>
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8085" basePath="/api" doc:name="HTTP Listener Configuration"/>
    <flow name="test_salesforce">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/salesforce" doc:name="HTTP"/>
        <logger message="#[payload]" level="INFO" doc:name="Logger"/>
        <dw:transform-message doc:name="Transform Message" metadata:id="52df12c8-b314-4410-a313-ac1dbb630911">
            <dw:input-payload mimeType="application/json"/>
            <dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
{
Name: payload.Name,
BillingStreet: payload.BillingStreet,
BillingCity: payload.BillingCity,
BillingState: payload.BillingState,
BillingPostalCode: payload.BillingPostalCode,
BillingCountry: payload.BillingCountry
}]]></dw:set-payload>
        </dw:transform-message>
        <sfdc:create-single config-ref="Salesforce__Basic_Authentication" type="Account" doc:name="Salesforce">

        </sfdc:create-single>
        <set-payload value="Account has been successfully created" doc:name="Set Payload"/>
    </flow>
</mule>