Help

Substitute Formula as part of an automation

Topic Labels: Automations
983 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Alivia_Smith
5 - Automation Enthusiast
5 - Automation Enthusiast

Hello,

I’m trying to have an automation with a find and replace step inside it.
I’m just trying to fix a bug with connected fields when they have a coma so I need to remove the commas and copy paste into another field. And I can’t find a simple automated find and replace script (or write JS)? Is there a way to use a formula in the automations?
For now I have a workaround where I have a formula field and then I copy paste that formula field to a connected field - but would love to just merge that into one process!

Thanks

2 Replies 2

If you’re trying to eliminate the formula field your only other option really is to use a script. In Javascript, replacing a portion of text within a variable called string would be:

string.replace(searchvalue, newvalue)

To populate string with info from your Automation’s trigger record you would need to make string an input config variable (left side of the screen when editing an automation script). The full script would look something like this:

let {string} = input.config()
let newString = string.replace(",", "")
output.set("noCommas", newString)

Thank you for the amazing answer this worked great!

The only change I made was add a regex to replace all the occurrences (vs just the first one found)


let {string} = input.config()

let newString = string.replace(/,/g, "")

output.set("noCommas", newString)

Amazing community as always Heart