TRIM
Use TRIM on text to removes all spaces from text except for single spaces between words.
Use
TRIM( text )
Removes spaces from text.
| Parameter | Required | Description |
|---|---|---|
| text | Yes | the text to trim spaces from |
| Returns | Text |
Examples
Cleaning User Input for Data Consistency
You can use TRIM in an Input Mapping formula to ensure that data captured from a trigger remains clean and standardized before it is passed to subsequent steps or stored in a variable.
- Scenario: A user submits a "Project Title" via a Teams Trigger form, but they accidentally include extra spaces at the beginning or end (e.g., " New Budget Proposal ").
- Formula:
TRIM(@Trigger.out.ProjectTitle) - Logic:
@Trigger.out.ProjectTitle: This retrieves the raw text string from the trigger output.- Result: The function removes the leading and trailing "invisible" spaces, returning "New Budget Proposal". This prevents errors in later steps that might rely on exact text matches, such as in a Conditional Branch.
Validating Meaningful Content in Forms
You can use TRIM in an Output Validation formula to ensure that a required field contains actual characters rather than just empty spaces.
- Scenario: You have a "Comments" field that is mandatory. You want to prevent users from bypassing the requirement by simply typing a few spaces.
- Formula:
ASSERT(LEN(TRIM(this)) > 0, "This field cannot be empty or contain only spaces.") - Logic:
this: In validation, this keyword refers to the current value of the field being checked.TRIM(this): This removes all spaces from the user's input.LEN(...): This calculates the number of remaining characters.
- Result: If a user enters only spaces, the TRIM function reduces the input to an empty string with a length of 0. The ASSERT function then triggers the specified error message because the condition (Length > 0) is FALSE.