In this blog, we are going to discuss about how we can connect MuleSoft with Salesforce Environment and creates the records on it.
pre-requisite :-
1) Anypoint platform - (https://anypoint.mulesoft.com/login/signin) -> Sign in -> Anypoint studio(Download).
2) Java 8 -> (https://www.oracle.com/in/java/technologies/javase/javase8-archive-downloads.html)
3)Salesforce environment -> (https://login.salesforce.com)
Steps :-
1) Go to AnyPoint platform -> File -> New -> Mule Project.
2) Give the mulesoft project name and click on Finish.
3)On the left hand side you can see your project under package explorer.
4)Now, you are seeing "To get started, drag an operation or scope from mule palette". Now to get started we have to pull one component from mule palette(Which is on the right hand side of the main screen) and drop into the main screen.
5)For us, you have to drag "Listner(HTTP)" component from the mule palette and drop into the main screen.
6)Now your screen will look like below screen shot.
7) Now just below the main screen, we can see the properties of "Listner(HTTP)" component.
8) Into the General property, under basic setting, you have to click on "+" icon to integrate your mulesoft with your local host.
9) You will a new screen, there you can see "HTTP Listner config" with protocol, host and port. This is because we are running our application in localhost. You just have to Test the connection and if the connection is successful, hit the ok button. If not, try to change the port number and do the same thing again.
10) After that you have to give the path, which is below the basic setting. You can give any any name like this '/salesforcewallah'.
11) Now, you have to pull the any salesforce component, So for the time being I m taking create call.
12) Go to login.salesforce.com -> go to setting under avatar icon -> then click on 'Reset my security token'. This helps us to create the connection with the Mulesoft.
13) You can see you will get a mail with token and username.
14) Now in salesforce create call component, You have to go to connector configuration and fill out the necessary details. You can refer the below screen shot for this.
16) So to test this, You can add one "Transform Message" component between the listner and salesforce create component. Now go to transform component properties to map the fields with salesforce object.
17) Beside payload, you can see Define metadata, you have to click on it and give the metadata type and add type id as anything.
[{
"name":"salesforce wallah aaaaaa",
"billingCity":"London"
},
{
"name":"salesforce wallah aaaaaa",
"billingCity":"London"
},
{
"name":"salesforce wallah aaaaaa",
"billingCity":"London"
}]
18) Copy the above code and paste into the json file and select the Type as JSON and schema should be Example. Select the JSON file and it will create an json type data.See the below screenshot for your reference.
19) Now we have to write the mapping code with the salesforce object.Please refer below screenshot or your reference.
Mapping code
payload map (item, index) ->
Comments
Post a Comment
Please Write your comment here.