Cloudy in the meadow next to text that says "Transform Your Data with the MuleSoft Composer Custom Expression Editor."

Introducing the MuleSoft Composer Custom Expression Editor

By

As admins, you know that the needs of your business stretch beyond the bounds of a cookie-cutter approach—especially when it comes to integrations and automation. We kept this in mind as we built MuleSoft Composer for Salesforce, the no-code integrations and automation tool built for admins. Today, we are introducing a new formula editor feature to MuleSoft Composer, which empowers you to move beyond the basic data transformations and into complex manipulation of data. Let’s explore more!

Up until today, MuleSoft Composer has traditionally supported basic transformations like one-to-one mapping. For example, if you’re interested in setting a value for a field in your target system, you can select a data pill, which represents data already existing in your flow from a previous step.

However, what if you want to move beyond the basics of one-to-one mapping? That’s where the MuleSoft Composer Custom Expression Editor comes into play. The editor is a scalable and intuitive tool that allows you to add custom expressions and formulas to your fields. We’ve taken the best of DataWeave, MuleSoft’s powerful and adaptable data transformation language, all while drawing inspiration from existing, intuitive Salesforce formula design patterns you’re already familiar with. The first version of this editor supports basic math manipulations along with string, date, and number functions.

Follow along with me as we take a look at this new feature in action!

Use Case 1: Formulas in regular field mappings

In the example shown below, I have an order closing in Salesforce, and I’m creating a sales order in NetSuite. However, I want to move beyond the basics of mapping in fields. Here, I want to set the three fields you see in the image below—Revenue Recognition End Date, Name, and Cost Estimate—using different formulas.

The OrderFlow Composer for creating a record.

Date manipulations

The first field I’ll tackle is the Revenue Recognition End Date (note it’s a date/time field). As I open the Custom Expression Editor, I see a list of all the functions on the left-hand side, and I can start to build out an expression.

The Custom Expression Editor in Composer searching for a function using the word “add”.

As a part of this new functionality, you can also expect help text and examples to appear in line along the way to help you understand what you’re building. Because setting dates and date/times dynamically (like “today” and “now”) has been such a frequent ask from users, we’ve gone ahead and included such expressions! Take a look at the “now” function in action in the expression I created to set the revenue end date to 30 days from today:

The Custom Expression Editor in Composer with the Revenue Recognition End Date set to 30 days from now.

This expression will always set the Revenue Recognition End Date to be 30 days from when the flow executes (that is, now).

String manipulations

Next up, we’re going to set the Name field to explore what it would be like to set up a string manipulation. Instead of just mapping in the account as is, I want to ensure it’s capitalized properly for my end system. In this case, I’ll use the capitalize function to wrap the Account Name data pill.

While this is a pretty simple example, it’s important to set the foundation so you can confidently tackle more complex use cases where you’ll want to manipulate strings—so that the end system takes them as expected.

Using the Custom Expression Editor to capitalize the Account Name.

Number manipulations and basic math

And lastly, let’s apply some basic math to set a Cost Estimate for this field. In my example, I want to multiply two values together to get the cost estimate. First, I toggle over to the Data menu header and then search for and select Quantity.

Using the Custom Expression Editor to search for the Quantity value.

Once I select Quantity, I toggle to the Operators menu heading, then select Multiply (or use the shortcut command to type it).

The Custom Expression Editor with the multiple expression added after the Quantity field.

Next, to finish off my basic equation, I toggle back to the Data menu header, then search for and select Unit Price.

The Custom Expression Editor with Unit Price added as a new field after the multiplication expression.

While this was a basic mathematic expression—and you could have done this multiplication in Salesforce via a formula field and then mapped that custom field into NetSuite—the power of this formula in Composer increases when you’re performing math on fields coming from multiple disparate systems.

Use Case 2: Formulas in the Query Builder

Another common use case is to include a relative date/time in your flow. This is particularly important when operating on records within a specific time frame. You can leverage the Custom Expression Editor and relative dates within the Get Records step (Query Builder) to accomplish this.

In this scenario, I’m pulling in opportunities that have closed in the last 7 days:

The Get Records step with a formula for the Close Date in the last 7 days.

How does using the Custom Expression Editor compare to other Salesforce formula editors?

Keep in mind that the Composer Custom Expression Editor is not built on top of Salesforce’s formula engine, but rather uses MuleSoft’s DataWeave language under the covers. This means that the formulas offered and overall syntax may occasionally differ. Please reference the Composer documentation for the full list of supported formulas and their definitions.

One example of this diversion is date arithmetic. As you’ve seen in the above examples, to add 5 days to a close date, you would build the formula “addDays(Close Date, 5)” rather than “Close Date + 5.”

Additionally, in Composer, you build the expression at the site of the field where you want to use it. Unlike Flow Builder, it’s not created as a separate resource in the flow. If you want to leverage the same expression in multiple locations, simply copy and paste.

Other than that, the overall experience should feel very familiar. Simply combine formulas, operators, and data pills (like merge fields!).

On top of all this, there are a couple of awesome features to check out. The editor provides immediate syntax validation in real time with helpful error messages. This ensures you’re on the right track while building the expression and have no data type mismatches or missing parameters. A context popover also provides in-app documentation and examples for each formula.

And there you have it! You’ve now successfully completed four different transformations and manipulations of the data within your flow, and have a better understanding of how Composer’s Custom Expression Editor compares to other Salesforce formula editors.

Remember, this is just the first version! We’ll be iterating and introducing new formulas and capabilities throughout the year. Up next, typecasting functions! Don’t see a formula you want? Please submit an idea on the IdeaExchange or let us know on the Trailblazer Community.

Resources

Image of Salesforce characters on a green field next to text that says, "Trailblazer DX '22 Admin Recap."

6 TrailblazerDX ’22 Takeaways for Salesforce Admins

Two weeks ago, TrailblazerDX returned, marking our first big in-person event together in more than 800 days! The energy, enthusiasm, and excitement on-site was equally matched by those joining us on Salesforce+, with two full days of content, connection, and collaboration. From keynotes to campfires and everything in between, TDX ’22 was full of knowledge […]

READ MORE
Cloudy towing Einstein on water skiis next to text that says "Learn Moar: #2 Flow Enhancements."

Learn MOAR in Summer ’22 with Flow Enhancements 🔁

Follow and complete a Learn MOAR Summer ’22 trailmix for admins or developers by July 31, 2022, 11:59 pm PT to earn a special community badge and be automatically entered for a chance to win one of five $200 USD Salesforce Certification vouchers. Restrictions apply. Learn how to participate and review the Official Rules by […]

READ MORE
Greenery and text that says, "Automate the Assignment and Removal of Permission Set Groups." "

Automate the Assignment and Removal of Permission Set Groups

In the first episode of Automate This!, a new livestream content series focused on all things automation, I presented a solution for automating the assignment and removal of permission sets. This blog post will cover a related solution, the automation of the assignment and removal of permission set groups. Don’t know what permission set groups […]

READ MORE

Have an Idea for a Story?

We are all about the community and sharing ideas.
Do you have an interesting idea or useful tip that you want to share?

SHARE YOUR IDEA