Trying to format a phone number stored as +1XXXXXXXXXX into (XXX) XXX-XXXX using an Architect Expression. Here is what I have so far:
${if(endsWith(data.phoneNumber, 'X'), concat('(', substr(data.phoneNumber, 3, 3), ') ', substr(data.phoneNumber, 6, 3), '-', substr(data.phoneNumber, 9, 4)), data.phoneNumber)}
The expression evaluates to null or throws a syntax error when the input contains the +1 prefix. Not sure if the substr indices are off or if there’s a better way to handle the prefix stripping in the expression builder.