ABSYZ ABSYZ

  • Home

    Home

  • About us

    Who We Are

  • Our Expertise

    What we Do

  • Our Approach

    How We Do It

  • Products

    What We Made

  • Industries

    Who We Do It For

  • Clients

    Whom We Did It For.

  • Article & Blogs

    What Experts Think

  • Careers

    Join The Team

  • Get In Touch

    Let’s Get Started

ABSYZ

Return Requested Data from Salesforce Multiple Data Sources using MuleSoft

Home / Article & Blogs / Salesforce / Integration / Return Requested Data from Salesforce Multiple Data Sources using MuleSoft
By Sisira Kosuri inIntegration, Salesforce

This blog walks you through the Integration between Salesforce and  Mulesoft Anypoint Studio. Consider a scenario that returns requested records from multiple Salesforce orgs. Consider Account object  with an External ID field  named as Account Code which  allows alphanumeric inputs. This flow will receive the Account Code as a JSON input via a HTTP listener and it will search for the Account Code from two Salesforce Orgs and return the Account and its related opportunity information as a response to the HTTP request.

Response Criteria:

  • If there is no record in Org 1 with the matching Account Code, then there should be an Error JSON returned to the user.
  • If there is no record in Org 2 with a matching Account Code, then the response should return with blank values in the JSON fields.
  • If there is record in both the Org’s with a matching Account Code, then the response should return combined records from both Org’s as a single JSON

Required Softwares:

  1. Anypoint Studio (version: 7.3.2)
  2. Postman

Mule Flow:

  1. In Anypoint Studio, Go to file -> select new Mule project -> Name the project.
  2. Now from Mule palette drag and drop the Listener followed by Set Variable component. So this is our main flow.
  3. In order to create seperate flows Fetch_From_org1 and Fetch_From_org2, drag and drop the Query Salesforce connector to the canvas away from the mainflow. This will automatically create a seperate flow.

Capture

flow1.PNG

flow3

So there are 2 flows named Fetch_From_org1 and Fetch_From_org2 other than the main flow. Fetch_From_org1 handles salesforce org1 and Fetch_From_org2  handles salesforce org2.

Fetch_From_org1 Process:

Use the Salesforce Query connector and fetch the Account and its related opportunity records with the matching Account code sent from the Postman http request. Add Transform Message Component to transform the query results to desired JSON format. Finally set the result payload to a variable named ‘org1_payload’. (In mule we can use the variable content through out the flow.)

Fetch_From_org2 Process:

Similarly query and transform the results of second org to required JSON format and set the result payload to another variable named ‘org2_payload’.

Main Flow:

Now the main flow starts with the listener followed by Set Variable component which stores the Account Code send in the request.

Postman Request:

Postman Request

Using Flow Reference component we can switch to another flow that exists in the same project. So refer these two flows in the main flow with the help of Flow Reference. Add the choice component to check the conditions(Choice component is similar to  if and else conditional statement). Here we have three conditions to check.

  • First check if the payload of org1,  stored in org1_payload variable is empty, then set another variable with error message. Now set the payload with that error message variable and use Transform Message component to transform the error message to JSON format.
  • Check if the payload of org2,  stored in org2_payload variable is empty if so then set another variable to null. Now set the payload with that null variable and use Transform Message component to transform the error message to JSON format.
  • This is default block where records exists  in both the orgs. Use Transform Message component to combine the payload from both  orgs to JSON format.

Code:

code1code2code3code4code5

Output for 3 conditions:

Anypoint StudioMuleSoft
99
Like this post
3 Posts
Sisira Kosuri

Search Posts

Archives

Categories

Recent posts

BioAsia 2023 in Hyderabad: An Annual International Event

BioAsia 2023 in Hyderabad: An Annual International Event

The Role Of Marketing in Small & Medium Enterprises

The Role Of Marketing in Small & Medium Enterprises

Salesforce For Retail: How Salesforce CRM Can Help Retailers

Salesforce For Retail: How Salesforce CRM Can Help Retailers

What is ChatGPT & How Does It Work?

What is ChatGPT & How Does It Work?

What Is Graphic Design? (Executive Summary 2023)

What Is Graphic Design? (Executive Summary 2023)

  • Previous PostContinuous Integration in Salesforce using Jenkins and Bitbucket
  • Next PostCustomizing the Markers in your Leaflet map
    Continuous Integration in Salesforce using Jenkins and Bitbucket

Related Posts

Salesforce For Retail: How Salesforce CRM Can Help Retailers
Salesforce

Salesforce For Retail: How Salesforce CRM Can Help Retailers

Introduction To Copado Devops Tool
Salesforce

Introduction To Copado Devops Tool

What is Salesforce Code Builder?
Salesforce

What is Salesforce Code Builder?

Automation in Healthcare And Its Benefits
Health Cloud Salesforce

Automation in Healthcare And Its Benefits

Leave a Reply (Cancel reply)

Your email address will not be published. Required fields are marked *

*
*

ABSYZ Logo

INDIA | USA | UAE

  • About us
  • Article & Blogs
  • Careers
  • Get In Touch
  • Our Expertise
  • Our Approach
  • Products
  • Industries
  • Clients
  • White Papers

Copyright ©2022 Absyz Inc. All Rights Reserved.

youngsoft
Copy
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “ACCEPT ALL”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent. Privacy Policy
Cookie SettingsREJECT ALLACCEPT ALL
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled

Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.

CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.

Functional

Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.

Performance

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

Analytics

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.

Advertisement

Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.

Others

Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.

SAVE & ACCEPT