DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Configuring a Shopify MuleSoft Connector
  • Handle HL7 MLLP Messages With Mule 4
  • SharePoint Integration With MuleSoft
  • Configuring Amazon S3 Using Mulesoft

Trending

  • Enforcing Architecture With ArchUnit in Java
  • MCP Servers: The Technical Debt That Is Coming
  • GitHub Copilot's New AI Coding Agent Saves Developers Time – And Requires Their Oversight
  • The Future of Java and AI: Coding in 2025
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. MuleSoft, Salesforce UPSERT

MuleSoft, Salesforce UPSERT

Let's take a look at how to create a simple global HTTP connector to receive requests.

By 
Ugo Augusto Gustavo Guazelli user avatar
Ugo Augusto Gustavo Guazelli
·
Updated Aug. 14, 18 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
28.3K Views

Join the DZone community and get the full member experience.

Join For Free

HTTP Config:

MuleSoft has Salesforce connectors that facilitate CRUD operations for Salesforce objects. Take a look at MuleSoft, Salesforce Request and MuleSoft, Salesforce POST for more information

HTTP Connector:

We are going to create a simple global HTTP connector to receive our requests:

Image title

To make the example simple, we are going to create the following flow:

  • /contacts PUT

Image title

HTTP config:

Image title

Salesforce Connector:

Drag and drop the Salesforce connector right after the GET HTTP:

Image title

  • Select Salesforce Basic Authentication
  • Fill out the username, password, and security tokens with Salesforce credentials.
  • Click validate configurations to check the connection.

Image title

Salesforce Upsert:

In upsert operation, Salesforce internally validates the data based on Object's Id or External ID. So, upsert takes a little bit longer time than insert or update. Using the upsert operation, you can either insert or update an existing record in one call.

In this example, we are going to use email as the External ID Field Name. In other words, the email passed in the paylod will be validated whether it exists, if so, the object will be updated, otherwise, a new object will be created.

Image title

Drag and drop a transformer connector between HTTP and Salesforce. Doing that, you can make use of the data sense to help you to make the transformations.

Image title

Image title

We are going to use the following payload to create a contact:

{
"last_name": "Obama",
"first_name": "Barack",
"cel": "555 6987",
"personal_email": "bo@whitehouse.com"
}

The MuleSoft Transformer should look like this:

%dw 1.0
%output application/java
---
[{
LastName: payload.last_name,
FirstName: payload.first_name,
Phone: payload.cel,
Email: payload.personal_email
}]

Image title

NOTE: Pay special attention to %output, as it should be application/java

Add another transformer connector after the Salesforce connector. It will be responsible for transforming the resulted Salesforce message into JSON format.

Image title

The transform message should look like this:

%dw 1.0
%output application/json
---
{
    id: payload[0].id,
    success: payload[0].success
}

Image title

UPSERTING a Contact

Start the Mule project from Postman, make a post request, and pass the contact JSON as a parameter:

Image title

The JSON response should indicate if the contact was properly created or updated.

Opening Salesforce, we can find our created Contact (Barak Obama).

Image title

If you sent another contact, keeping the same email but changing other fields, you can check the contact updated.

MuleSoft Connector (mathematics)

Opinions expressed by DZone contributors are their own.

Related

  • Configuring a Shopify MuleSoft Connector
  • Handle HL7 MLLP Messages With Mule 4
  • SharePoint Integration With MuleSoft
  • Configuring Amazon S3 Using Mulesoft

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!