Hu @EmmaAtKiwi - I may be confused, but it looks to me that you are trying to use the regex function in a workflow format step. But the reference you are making to the usage docs is for a HubL function.
I know very well that the differences/inconsistencies between HubSpot tools and different conexts can be maddening sometimes.
I was struggling with a similar issue. After many hours of frustration I found what appears to be a bug in the data formatting implementation of regex_replace. I found that although the editor was accepting my input variable as a valid type, somewhere later down the line it was rejecting it. By forcing/coerding the input value into a string using another function I got it to work (I used "cut()" with no value). In my case I'm taking an 8 digit phone number and adding a country code:
I was struggling with a similar issue. After many hours of frustration I found what appears to be a bug in the data formatting implementation of regex_replace. I found that although the editor was accepting my input variable as a valid type, somewhere later down the line it was rejecting it. By forcing/coerding the input value into a string using another function I got it to work (I used "cut()" with no value). In my case I'm taking an 8 digit phone number and adding a country code:
I know this thread is a little older, but I also know how frustrating it can be to not find a solution! This is a bit more advanced, but I've found it works really well for what you're trying to accomplish, @EmmaAtKiwi., and includes some instructions to help give context. You want the cca.js file to use as a custom code action instead of a formula...
Gives two options for formatting US phone numbers. To get the +1, I just modifed line 74 slightly:
Hu @EmmaAtKiwi - I may be confused, but it looks to me that you are trying to use the regex function in a workflow format step. But the reference you are making to the usage docs is for a HubL function.
I know very well that the differences/inconsistencies between HubSpot tools and different conexts can be maddening sometimes.
@EmmaAtKiwi - I think my point is that your function reference is to a HubL document which really is a different language to the custom formula seup in workflow steps. So you can't mix and match thos functions. HubL functions can only be used in page markup/HTML scripting etc.
Hope that this makes sense. Apologies if I am getting teh context incorrect.
Thank you @SteveHTM, you're absolutely getting it correct, it's ME that's clearly struggling! So if my syntax deduced from the HubL doc won't work, do you know what will?
Emma Washington
HubSpot Director @ Kiwi Creative
3x Accredited HubSpot Platinum Partner
HubSpot Certified Trainer Leader of B2B Technology (USA) HubSpot User Group
Nov 15, 202311:51 AM - edited Nov 15, 202311:51 AM
Top Contributor | Platinum Partner
Regex_replace to format phone numbers
SOLVE
Thanks @BérangèreL! Unfortunately, clicking on "show details" does not, in fact, give me any details... The error message only reiterates that I wrote the syntax wrong, but I don't know where!
Emma Washington
HubSpot Director @ Kiwi Creative
3x Accredited HubSpot Platinum Partner
HubSpot Certified Trainer Leader of B2B Technology (USA) HubSpot User Group
This will take care of formatting numbers like 8004567890 or 18004567890 into +1 (800) 456-7890.
The changes I made is adjusting the placement of the capturing groups and fixing the pattern for the optional '1'. Give it a shot, and hopefully, it solves the problem for you.
I would love know how it goes on triotech systems! If you still run into issues, we can dive deeper into troubleshooting. Good luck!
Nov 10, 20236:05 AM - edited Nov 10, 20236:05 AM
Community Manager
Regex_replace to format phone numbers
SOLVE
Hi @EmmaAtKiwi👋, I hope that you are keeping well!
Thank you for asking the Community, great question!
I understand that you are using a custom coded workflow action to format phone numbers but you get an error. If that's not correct, please let me know.
- When you click on "show details" regarding the error message, what does it say, please? The more info, screenshots (without sensitive/confidential information), and details you can provide, the better the Community can assist.
I'd like to invite a couple of subject matter experts to this conversation: Hi @louischausse, @ChrisoKlepke and @Teun do you have suggestions to help @EmmaAtKiwi, please?
Also, if anybody else has anything to add and/or share, please feel free to join in the conversation 🙂
Thank you very much for sharing your expertise ❤️ and have a wonderful day!