Building Formulas for Flows
Manipulate data in Composer by building expressions and applying functions. Using the Custom Expression Editor, create expressions that include functions and mathematical operators. Use the editor also to truncate words, capitalize phrases, and set the date.
When building formulas for a flow, keep in mind that:
-
You can nest functions and use the input parameters of another function call for your function.
-
Composer functions used in Composer are built using DataWeave.
-
Composer functions treat empty spaces as empty space characters in a formula.
String Functions
The Custom Expression Editor supports the following string
formulas and operators:
Function Name | Description | Example | Parameter Definition | Input Data Type Parameters | Output Data Type |
---|---|---|---|---|---|
lower |
Returns the provided string in lowercase characters. |
|
NA |
text: String |
String |
upper |
Returns the provided string in uppercase characters. |
|
NA |
text: String |
String |
capitalize |
Capitalizes the first letter of each word in a string. This also removes underscores between words and puts a space before each capitalized word. |
|
NA |
text: String |
String |
trim |
Removes any blank spaces from the beginning and end of a string. |
|
NA |
text: String |
String |
first |
Returns the specified number of characters from the beginning of a string. If the number is equal to or greater than the number of characters in the string, the function returns the entire string. |
|
NA |
text: String numCharacters: Number |
String |
last |
Returns the specified number of characters from the end of a string. |
|
NA |
text: String numCharacters: Number |
String |
substitute |
Replaces all substrings that match a literal search string with a specified replacement string. Replacement proceeds from the beginning of the string to the end. For example, the result of replacing |
|
NA |
text: String target: String replacement: String |
String |
fromStringToBoolean |
Transforms a string input value into a boolean value. |
|
NA |
text: String |
Boolean |
fromStringToDate |
Transforms a string input value into a date value. Accepts a format and locale. The format parameter represents the format of the input string. The default format is |
|
Format: The format parameter represents the format of the input string. This parameter accepts Java character patterns based on ISO-8601. A Date value, such as Locale: Optional ISO 3166 country code to use, such as |
text: String format: String locale: String |
Date |
fromStringToDateTime |
Transforms a string input value into a dateTime value.
Accepts a format and locale. The format parameter represents the format of the input string.
The default format is |
|
Format: The format parameter represents the format of the input string. This parameter accepts Java character patterns based on ISO-8601. A DateTime value, such as Locale: Optional ISO 3166 country code to use, such as |
text: String format: String |
DateTime |
fromStringToNumber |
Transforms a string input value into a number value. |
|
NA |
text: String |
Number |
emptyString |
Returns an empty string. You can use the emptyString function wherever an empty string is needed, including as an input parameter in other functions. |
|
|
String |
|
substring |
Returns a substring that spans from the character at the specified |
|
N/A |
text: String from: Number until: Number |
String |
It is important to note that in a string
field, you can use number
expressions selected from the operator list; however, the expressions must be enclosed within parentheses. For example, you can enter abc(9+9)
where the +
is selected from the operator list. This string renders as abc18
.
Number Functions
In the Custom Expression Editor, a mathematical operator (+,-,*, or /) selected from the operator list is different from an operator typed and resolved as a string character. For example, the entry 9+9
is considered a string rather than 18
. To use mathematical operators, select them from the operator list or type and select them using the Enter key, Tab key, or mouse with typeahead.
The Custom Expression Editor supports the following number
formulas and operators:
Function Name | Description | Example | Parameter Definition | Input Data Type Parameters | Output Data Type |
---|---|---|---|---|---|
round |
Rounds a number up or down to the nearest whole number. |
|
NA |
number: Number |
Number |
ceil |
Rounds a number up to the nearest whole number. |
|
NA |
number: Number |
Number |
floor |
Rounds a number down to the nearest whole number. |
|
NA |
number: Number |
Number |
abs |
Returns the absolute value of a number. |
|
NA |
number: Number |
Number |
fromNumberToString |
Transforms a number value (whole or decimal) into a string value. |
|
NA |
number: Number |
String |
fromNumberToDateTime |
Transforms a number input value into a dateTime value. Uses milliseconds or seconds as the unit. The default unit is seconds. |
|
Unit: The unit of time to use for the conversion: "milliseconds" or "seconds". The default unit is "seconds." |
unit: String |
DateTime |
Date Functions
In the Custom Expression Editor, date
and dateTime
data pills can only be used as inputs. You cannot enter the dates manually.
The Custom Expression Editor supports the following date
and dateTime
formulas and operators:
Function Name | Description | Example | Parameter Definition | Input Data Type Parameters | Output Data Type |
---|---|---|---|---|---|
today |
Returns the date for today as a Date type. |
|
NA |
NA |
Date |
now |
Returns a DateTime value for the current date and time. |
|
NA |
NA |
DateTime |
addDays |
Creates and returns a Date value incremented or decremented by the specified number of days. |
|
NA |
date: Date numDays: number |
Date |
addDays |
Creates and returns a DateTime value incremented or decremented by the specified number of days. |
|
NA |
dateTime: DateTime numDays: number |
DateTime |
addMonths |
Creates and returns a Date value incremented or decremented by the specified number of months. |
|
NA |
date: Date numMonths: number |
Date |
addMonths |
Creates and returns a DateTime value incremented or decremented by the specified number of months. |
|
NA |
dateTime: DateTime numMonths: number |
DateTime |
addYears |
Creates and returns a Date value incremented or decremented by the specified number of years. |
|
NA |
date: Date numYears: number |
Date |
addYears |
Creates and returns a DateTime value incremented or decremented by the specified number of years. |
|
NA |
dateTime: DateTime numYears: number |
DateTime |
addHours |
Creates and returns a DateTime value incremented or decremented by the specified number of hours. |
|
NA |
dateTime: DateTime numHours: number |
DateTime |
addMinutes |
Creates and returns a DateTime value incremented or decremented by the specified number of minutes. |
|
NA |
dateTime: DateTime numMinutes: number |
DateTime |
addSeconds |
Creates and returns a DateTime value incremented or decremented by the specified number of seconds. |
|
NA |
dateTime: DateTime numSeconds: number |
DateTime |
beginningOfHour |
Returns a new DateTime value that changes the Time value in the input to the beginning of the specified hour. The minutes and seconds in the input change to 00:00. |
|
NA |
dateTime: DateTime |
DateTime |
beginningOfDay |
Returns a new DateTime value that changes the Time value in the input to the beginning of the specified day. The hours, minutes, and seconds in the input change to 00:00:00. |
|
NA |
dateTime: DateTime |
DateTime |
beginningOfWeek |
Returns a new Date value that changes the Day value from the input to the beginning of the first day of the specified week. The function treats Sunday as the first day of the week. |
|
NA |
date: Date |
Date |
beginningOfWeek |
Returns a new DateTime value that changes the Day and Time values from the input to the beginning of the first day of the specified week. The function treats Sunday as the first day of the week. |
|
NA |
dateTime: DateTime |
DateTime |
beginningOfMonth |
Returns a new Date value that changes the Day value from the input to the first day of the specified month. |
|
NA |
date: Date |
Date |
beginningOfMonth |
Returns a new DateTime value that changes the Day value from the input to the first day of the specified month. The day and time in the input changes to |
|
NA |
dateTime: DateTime |
DateTime |
beginningOfYear |
Returns a new Date value that changes the Month and Day values from the input to the first day of the specified year. |
|
NA |
date: Date |
Date |
beginningOfYear |
Returns a new DateTime value that changes the Month and Day values from the input to the first day of the specified year. It also sets the Time value to |
|
NA |
dateTime: DateTime |
DateTime |
daysBetween |
Returns the number of days between two dates. If the to Date value is earlier than the from Date value, the function returns a negative number equal to the number of days between the two dates. |
|
NA |
from: Date to: Date |
Number |
daysBetween |
Returns the number of days between two DateTime values. If the to DateTime value is earlier than the from DateTime value, the function returns a negative number equal to the number of days between the two DateTime values. |
|
NA |
from: DateTime to: DateTime |
Number |
month |
Returns the numerical value of the month in the Date input. |
|
NA |
date: Date |
Number |
month |
Returns the numerical value of the month in the DateTime input. |
|
NA |
dateTime: DateTime |
Number |
year |
Returns the numerical value of the year in the Date input. |
|
NA |
date: Date |
Number |
year |
Returns the numerical value of the year in the DateTime input. |
|
NA |
dateTime: DateTime |
Number |
fromDateToString |
Transforms a date input value into a string value. Accepts a format and locale. The format parameter represents the required format of the output string. The default format is |
|
Format: The ISO-8601 formatting to use on the Date. It represents the desired format of the output string. For example, this parameter accepts character patterns based on the Java 8 java.time.format. The default format is Locale: Optional ISO 3166 country code to use, such as |
date: Date format: String locale: String |
String |
fromDateTimeToString |
Transforms a dateTime input value into a string value. Accepts a format and locale. The format parameter represents the desired format of the output string. The default format is |
|
Format: The ISO-8601 formatting to use on the DateTime. It represents the desired format of the output string. For example, this parameter accepts character patterns based on the Java 8 java.time.format. The default format is Locale: Optional ISO 3166 country code to use, such as |
dateTime: DateTime format: String locale: String |
String |
fromDateTimeToNumber |
Transforms a dateTime input value into a number value. The number is in milliseconds or seconds, depending on the selected unit. The default unit is seconds. |
|
Unit: The unit of time to use for the conversion: "milliseconds" or "seconds". The default unit is "seconds." |
dateTime: DateTime unit: String |
Number |
fromDateToDateTime |
Transforms a date input value into a dateTime. It does so by adding a time. The default time is T00:00:00Z. All manual entries will be interpreted in UTC. |
|
NA |
date: Date time: String |
DateTime |
List Functions
The Custom Expression Editor supports the following List
formulas and operators:
Function Name | Description | Example | Parameter Definition | Input Data Type Parameters | Output Data Type |
---|---|---|---|---|---|
joinBy |
Merges a list into a single string value and uses the provided string as a separator between each item in the list. |
|
list separator Note that you cannot build a list manually to include |
list: List<String> separator: String |
String |
splitBy |
Splits a string into a list of strings based on a separating string that matches part of the input string. This filters out the matching string from the returned list. The separator can match any character in the input. |
|
text separator Note that you cannot build a list manually to include |
text: String separator: String |
List<String> |
Data Types
The value that a Composer field can accept for a value is a data type. In Composer, the following data types are available:
Data Type | Definition |
---|---|
Boolean |
Evaluates to |
Date |
Stores a year, month, and day as |
DateTime |
Stores a date and time within a time zone relative to Greenwich Mean Time (GMT). A time zone must include either the symbol |
List<Object> |
Returns a list of objects, for example, the output of the Get Records action. |
List<Primitive> |
Returns a list containing primitive data types. The following item data types are available: |
Number |
Stores either a floating-point number in the range of 1.40129846432481707e-45 to 3.40282346638528860e+38 or an integer. |
Object |
Refers to a composite data type that can contain other data types as properties ( |
String |
Stores text, numbers that are not |
Access the Custom Expression Editor
To access the Custom Expression Editor:
-
From the Composer Flows tab, open a flow.
-
Click Edit.
-
In an action field, in a value in the query builder, or in the value of an If/Else Block control, select Custom Expression fx from the drop-down menu.
The Custom Expression Editor appears.
Add a Custom Expression to an Action
When adding a custom expression, place the cursor over elements in the Custom Expression Editor window to trigger context popovers containing helpful suggestions and in-app support.
To add a custom expression to an action:
-
In the Custom Expression Editor left pane, click one of the following tabs:
-
Function, to view or search for a function
-
Data, to view or search for a field or data pill
-
Operator, to view or search for an operator
-
-
Select the available functions, fields, data pills, or operators for your custom expression from the left pane.
Your selections appear in the <Field Name> box in the right pane. The syntax of your custom expression is validated automatically. -
If you want to reuse the expression in the <Field Name> box in another field, copy it.
-
After the custom expression is created and validated, click Apply.
-
Click Save.
The custom expression is added to the field.
Edit a Custom Expression
To edit an existing custom expression in an action:
-
From the Composer Flows tab, open a flow.
-
Click Edit
-
In an action field containing your custom expression, click the pencil icon.
The Custom Expression Editor appears. -
In the <Field Name> box in the right pane of the Custom Expression Editor, either select and delete the existing custom expression or place your cursor where you want to add items from the left pane.
-
In the left pane, select from the available functions, fields, data pills, or operators.
Your selections appear in the <Field Name> box in the right pane. The syntax of your edited custom expression is validated automatically. -
After your custom expression is edited and validated, click Apply.
-
Click Save.
Your custom expression is edited.
Delete a Custom Expression
To delete an existing custom expression in an action:
-
From the Composer Flows tab, open a flow.
-
Click Edit
-
In an action field containing a custom expression, click the X icon.
The custom expression is deleted from the field. -
If your implementation requires this field to contain a value, either add a new custom expression or select a value from the drop-down menu.
-
On the Flow Details page, click Save.
The custom expression is deleted. If your environment requires a value in the custom expression field, your addition or selection is saved.