Hey folks,
Trying to clean up a phone number string coming from an external webhook. It arrives as +15551234567 and I need it formatted as (555) 123-4567 before passing it to a downstream API.
I’ve got the substring logic mostly figured out, but the parentheses are killing me. Architect doesn’t seem to like standard string concatenation with special chars in the way I’d expect. Here’s what I’ve tried:
concatenate("(", substring(data.PhoneNumber, 2, 3), ") ", substring(data.PhoneNumber, 5, 3), "-", substring(data.PhoneNumber, 8, 4))
It returns a null or empty string depending on how I test it in the expression builder. The input is definitely a string. Am I missing a step to escape the parens or is there a simpler regex replace function I’m overlooking?
Also, if the input is sometimes just 5551234567 (no +1), the substring indices obviously break. Should I wrap this in a conditional check first or is there a way to handle both formats in one expression?
Any help appreciated.