1

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!

1

Option 1

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: enter image description here enter image description here enter image description here

Here are the results in the UI: enter image description here

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.


Option 2

(Which I think is better)

You could put a Validation Rule on your original field to either

  • A. Make the user enter "https://"

OR

  • B. Not allow the user to enter "https://"

(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://'))

Here it is in action: enter image description here

And here I was able to save after adding "https://": enter image description here

*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://").

Here it is in action: enter image description here

And here I was able to save after removing "https://": enter image description here

*NOTE: If you use this option, you WOULD REQUIRE a separate Formula field as originally noted in Option 1.

4
  • Thanks a lot for this! however, it doesn't look like this way would take into account whether a user has added http by themselves and so this formula would then add http again?
    – ollieF
    Feb 22 '21 at 15:28
  • Hello ollieF - you could extend the above formula field to include a check the first characters of the string - You could use LEFT(TEXTFIELD__c, 5) to check if TEXTFIELD__c starts with HTTPS, then use an IF statement to either add HTTPS or not add it. Feb 22 '21 at 16:14
  • @ollieF : You are correct. I edited and appended my answer.
    – Moonpie
    Feb 22 '21 at 16:51
  • Thank you v much!!
    – ollieF
    Feb 24 '21 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.