Formatted Personalization Tokens



I have a contact form that when a user selects a checkbox, it runs through a workflow and then sends an internal email.

In this internal email it needs to populate a url param with contents of the form.


The problem falls mainly with the Company Name if I just use the regular token for this and the company has a space in their name it breaks the link.

I need to add a + where the space would be, it should look like Some+Company+Inc.




You can use hubl to re-format the string that comes in from the personalization token. Take a look at these docs here for a jump start on it.


Is there something specific I should be look for? I just did a quick scan of it and I cant seem to find anything that will be able to run something like a regex to replace a space with a +.


i am trying to use the replace() function, but it is not working.

{{|replace(' '),'+')}}

it still displays with the space and not the +



It looks like you have an extra ‘)’ in your code

Try it with this first

{{|replace(’ ‘,’+’)}}

If that doesn’t work let me know and I can create a working example on my end



that isnt work either, does replace() work in email templates?


@iamcenz Yes they do, I just tested it out on an email template and saw success. Here wast the test code I used.

{% set test = "test1 test2" %}
{{test|replace(' ','+')}}


@pmanca yes that seems to work, i got that working as well, i can not get it to work with {{}} the personalization token wont take the replace.

i tried to set as a new variable and trying it on that too but if i do
{% set companyName = {{}} %}
i get an error because it thinks im trying to create an array.



{% set companyName = "{{}}" %}
{% set dirtyCompany = "{{companyName|replace(' ','+')}}" %}

I just tried this, this doesnt work either. It seems like you can not modify a personalization token at all.


@iamcenz you are actually correct. My apologies. I did some more testing on my end and then confirmed with my manager @zwolfson that in the email took the personalization tokens are loaded after the hubl logic is executed so you cannot modify a personalization token as you mentioned.



So then there is no way for me to do what I need?


@iamcenz no there doesn’t appear to be. If I come across a solution I will let you know .



I found a work around. I created another field that was hidden, then used javascript to grab the value of the company field off focus. It then removes the space and adds the + then puts it in the hidden field.

I then use the personalization token of the hidden field in my email because it already was sent with + in there.


@iamcenz very cool! thanks for posting it here to help others who run into this problem down the road.