Greetings Hubl community! I'm new to the platform, just sort of learning on the fly. I've searched to no avail, but I have to figure there is a solution.
We are using {{contact.firstname}} for salutations both in the body content and Subject Lines.
The problem is, some of the client data has initials for their first name entries. So the salutation would read "Dear C.," for example. The client doesn't like that.
Is there a way to search the strings and specify that there must be more than two characters in order to write out the name? Otherwise, the less than two characters gets the default option instead?
The client would prefer to use Valued Member over C. for instance.
I'm still learning the syntax, so apologies if this is quite a newbie quesiton.
Hello "Valued Member" (see what I did there... your name is only 2 characters).
The best (and only) way I can think of is to use a hubl {% if %} conditional in a template.
As far as I know, when using email tokens you are forced to set the default for when there isn't ANY value for that property... Less than ideal, I know.
If you have access to (and are comfortable using) templates, you can very easily accomplish this with the following statement.
This code sets the variable fname equal to a property of contact.firstname (make sure that's the right syntax for firstname). It also has a fallback of an empty string (in case there's no firstname property).
Then we usea list filter (breaks the string into each character) and thelength filter(calculates the number of characters) wrapped in an "If statement" which checks if the length is greater than 2.
To actually add this into your email template, you'd want to select a HubL module from the drag-and-drop editor, bring it into the template above your email body section, then add the above code.
Once you've added the custom hubl module, add the chunk of code into it.
You may need to tinker with the position of the custom hubl module and you may also have to edit the CSS values of the module to match the padding / background of your email body, but this should accomplish what you're trying to do.
Hello "Valued Member" (see what I did there... your name is only 2 characters).
The best (and only) way I can think of is to use a hubl {% if %} conditional in a template.
As far as I know, when using email tokens you are forced to set the default for when there isn't ANY value for that property... Less than ideal, I know.
If you have access to (and are comfortable using) templates, you can very easily accomplish this with the following statement.
This code sets the variable fname equal to a property of contact.firstname (make sure that's the right syntax for firstname). It also has a fallback of an empty string (in case there's no firstname property).
Then we usea list filter (breaks the string into each character) and thelength filter(calculates the number of characters) wrapped in an "If statement" which checks if the length is greater than 2.
To actually add this into your email template, you'd want to select a HubL module from the drag-and-drop editor, bring it into the template above your email body section, then add the above code.
Once you've added the custom hubl module, add the chunk of code into it.
You may need to tinker with the position of the custom hubl module and you may also have to edit the CSS values of the module to match the padding / background of your email body, but this should accomplish what you're trying to do.
Thank you Mike! I appreciate your time! My coworker showed me the disclaimer on this that a lot of the custom stuff wouldn't work on email -- only on blogs and landing pages. So I wasn't sure if this was just a waste of time to ask.
If statements and filters do not work with contact properties in email templates. I wish it did as it would make my life easier! There are so many times that this would have solved a problem for me. Hopefully Hubspot will make this possible in the near future.