I have a field that contains a url. This url is sent to marketing cloud and the link only works if is prepended with "https://", how can i automatically add this if a user only enters "www.google.com"
Thanks!
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityI have a field that contains a url. This url is sent to marketing cloud and the link only works if is prepended with "https://", how can i automatically add this if a user only enters "www.google.com"
Thanks!
Create an additional Formula Field of type Text, with the formula being to concatenate 'https://' and your field which holds the URL.
I created an example of a URL data type field which I called Web Link, and then a Formula field which I called Web Link Formula from URL Field. Here is the creationg of the Formula field:
Here are the results in the UI:
NOTE: both are clickable links
You would not necessarily have to make your Formula field visible, and even if hidden you could just send the value of your Formula field to your marketing cloud.
EDIT
In order to not repeat the https://
in the case that a user enters it, you could wrap the formula in an IF
with a BEGINS
:
IF( BEGINS(Web_Link__c, 'https://') , Web_Link__c, 'https://' & Web_Link__c)
HOWEVER this is putting a lot of trust that the user will correctly enter the "https://".
And please note that this would only cover the case that a user entered "https://". Obviously the user could enter something invalid (like "https:") and you would end up with https://https:salesforce.stackexchange.com
.
(Which I think is better)
You could put a Validation Rule on your original field to either
OR
(You would select the option depending on your expectations of and relationship with your users.)
Option 2A: Make the user enter "https://"
Your validation rule would look like this:
NOT(BEGINS(Web_Link__c, 'https://'))
And here I was able to save after adding "https://":
*NOTE: If you use this option, you would NOT need a separate Formula field.
Option 2B: Not allow the user to enter "https://"
Your validation rule would look something like this:
BEGINS(Web_Link__c, 'http')
Using http
should cover almost everything a user might enter (e.g., "http:", "https://").
And here I was able to save after removing "https://":
*NOTE: If you use this option, you WOULD REQUIRE a separate Formula field as originally noted in Option 1.