LEFT
LEFT returns the first character or characters in a text string, based on the number of characters you specify.
Use
LEFT( text, [num_chars] )
Returns the leftmost characters from a text value.
| Argument | Required | Description |
|---|---|---|
| text | Yes | The text string that contains the characters you want to extract. |
| num_chars | No | Specifies the number of characters you want LEFT to extract. Must be greater than or equal to zero. If greater than the length of text, returns all of text. If omitted, assumed to be 1. |
| Returns | 'Text' |
Examples
Extracting a Name Prefix from a Field
You can use the LEFT function in an Input Mapping formula to shorten a piece of information, such as taking a full forename and displaying only the first few letters on a summary form.
- Scenario: You want to display a nickname or a short identifier for a customer based on their forename stored in a previous step.
- Formula:
LEFT(@LocateCustomer.out.Forename, 3) - Logic: The function targets the Forename output from the "LocateCustomer" activity.
- Result: If the forename in the source is "Benjamin", the function extracts the first three characters and returns "Ben".
Extracting the Category from a Numeric Code
Because GoApprove uses specific data types, performing text operations on numeric fields requires an extra step. This example demonstrates how to extract the first digit of a numeric product ID to determine its category.
- Scenario: A Trigger captures a numeric ProductCode (e.g., 55021). You need to extract the first digit to use in a Path Condition formula.
- Formula:
LEFT(TEXT(@Trigger.out.ProductCode), 1) - Logic:
@Trigger.out.ProductCode: Retrieves the numeric value from the trigger.TEXT(...): Converts that numeric value into a Text string, which is required becauseLEFTcannot accept a Number directly.LEFT(..., 1): Extracts the single leftmost character of that new text string.
- Result: If the code is 55021, the formula returns the text character "5".