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

Cloudy standing near a cliff and text that says, "Easy Integrations with Flow HTTP Callouts."

Integrations Are Easier Than Ever with Flow HTTP Callouts

Are you tired of waiting for IT resources to build out an integration to your supplier? Are you frustrated that your payroll system lacks reliable application programming interface (API) documentation, leaving your IT team to weed through JSON and just hoping it’ll work? Then Flow HTTP Callout is for you! This feature does the hard […]

READ MORE
Max sitting on a log next to text that says, "How to Integrate Salesforce Flow with MuleSoft RPA."

How to Integrate Salesforce Flow with MuleSoft RPA

Salesforce Flow empowers you to build complex business solutions using clicks, not code. Flow RPA provides the ability to automate repetitive tasks using RPA Bots. Together, admins can build powerful business workflows to achieve end-to-end automation. Let’s assume we have a use case for document processing. For this use case, we’ll need the ability to […]

READ MORE