Skip to main content

REPLACE

The REPLACE replaces part of a text value, based on the number of characters specified, with a new text value.

Use

REPLACE( old_text, start_num, num_chars, new_text )
Replaces matching parts of text with a replacement text value.

ParameterRequiredDescription
old_textYestext in which to replace some characters
start_numYesthe position of the character in old_text to replace with new_text
num_charsYesthe number of characters in old_text to replace with new_text
new_textYesthe text that will replace characters in old_text

ReturnsText

Examples

Masking Sensitive Information for Reviewers

In an Input Mapping formula, you can use REPLACE to partially hide sensitive data, such as a Credit Card or Social Security number, so that it is not fully visible to the person performing an approval task.

  • Scenario: You want to display a "Masked ID" in a manager's inbox that shows only the first four digits of an eight-digit account number.
  • Formula: REPLACE(@Trigger.out.AccountNumber, 5, 4, "****")
  • Logic:
    • old_text: Retrieves the AccountNumber from the trigger.
    • start_num: Begins the replacement at the 5th character.
    • num_chars: Replaces the next 4 characters.
    • new_text: Inserts four asterisks ("****") in that position.
  • Outcome: If the input was "12345678", the reviewer will see "1234**.**"

Updating Standardized Reference Codes

You can use REPLACE within a Variable Update formula to modify a prefix or a specific segment of a reference code as it moves through different stages of a workflow.

  • Scenario: A request is initially submitted with a "DRAFT-" prefix (e.g., "DRAFT-99"). When the request moves to the "Legal Review" activity, you want to update the variable $ProcessID to start with "FINAL-".
  • Formula: REPLACE($ProcessID, 1, 5, "FINAL")
  • Logic:
    • $ProcessID: The variable currently holding the text "DRAFT-99".
    • 1: The replacement starts at the very first character.
    • 5: It removes the 5 characters that make up "DRAFT".
    • "FINAL": It inserts the new word in its place.
  • Outcome: The variable is updated to "FINAL-99" before the step starts.