Skip to content
Documentation
Updated 2 minutes to read
Markdown

The replace Formula function returns the content with every occurrence of oldValue replaced by newValue.

Strip the ORD- prefix from an order id with replace, animated walkthrough (7.12)
Animated walkthrough: on the Order Received JSON of the Order-to-Cash demo, replace('ORD-', '', jsonPath('$.orderId', body)) removes the prefix from ORD-10005 and returns 10005.

replace('oldValue', 'newValue', content)
Parameter Required Description
'oldValue' Yes The text to find. It's matched as plain text, not as a pattern, and case-sensitive: 'order' doesn't replace Order. Use replaceregex for patterns.
'newValue' Yes The text to substitute. Use '' to remove oldValue.
content Yes The text to change: body, context, or the result of another function, such as jsonPath.

The content with all occurrences replaced. Content that doesn't contain oldValue is returned unchanged. When the content holds several values, the replacement runs on each value.

Example 1: Replace a word in the message body

Section titled “Example 1: Replace a word in the message body”
nodinite
replace('nodinite','The worlds most innovative product',body)
The worlds most innovative product

Test Expression tab: replace on the message body nodinite returns The worlds most innovative product
The whole body matches oldValue, so the result is newValue only.

Example 2: Replace a word in a context property

Section titled “Example 2: Replace a word in a context property”
Key Value
id nodinite
replace('nodinite','The worlds most innovative company',context('id'))
The worlds most innovative company

Test Expression tab: replace on the context value nodinite returns The worlds most innovative company
The value of the context property id is changed; the message body isn't used.

Example 3: Replace a word in several jsonPath values

Section titled “Example 3: Replace a word in several jsonPath values”
[{ "name": "Amazing Function" }, { "name": "Amazing Implementaion" }]
replace('Amazing','Cool',jsonPath('$..name', body))
Cool Function
Cool Implementaion

Test Expression tab: replace on two jsonPath values returns Cool Function and Cool Implementaion
jsonPath returns two values, and replace changes Amazing in each one: two unique matches.

...

Version:
Release date: N/A
Loading...

Explore Nodinite for 30 days – completely free

  • Find out why this is the leading O&M software
  • Prove your business case
  • Test the self-service for the business side

Loading...

See how Nodinite resolves your technical issues, in a LIVE Demo!

Once you submit this request:

  • We will give you a short call to understand the issues you want to tackle.
  • Understand solutions you have tried and why were you not happy with them.
  • Book a convenient slot for a LIVE demo!

Loading...