Hyperlink in a Rich Text Formula

  • 0
  • 1
  • Question
  • Updated 4 weeks ago
  • In Progress
Hi,

I am trying to create a rich text field that based on certain data either returns a plain text message or a hyperlink that is grabbed from another URL field on the same table. Below is what I have so far, but the Hyperlink though displaying correctly in the output is getting an error message when I click on it. I can confirm that the URL is correct though as it works when I click on it in the URL field.  

var text URLWords=ToText([URL Field])
var text URL="<a href="&[URL Field]&">"&$URLWords&"</a>";

If([FileAttached]=true, "File Attached",$URL)

Below is a pic of the error message I am receiving. Any help would be appreciated! 


Photo of Coleen Schmitt

Coleen Schmitt

  • 524 Points 500 badge 2x thumb

Posted 4 weeks ago

  • 0
  • 1
Try wrapping your href in single quotes 

HTML elements and their components need to be in quotes so the browser knows the difference.

So:
var text URL="<a href='"&[URL Field]&"'>"&$URLWords&"</a>";

for spacing so you can see where the single quotes are - dont use the below
var text URL="<a href=' "&[URL Field]&" '>"&$URLWords&"</a>";


Chayce Duncan | Director of Strategic Solutions
(720) 739-1406 | chayceduncan@quandarycg.com
Quandary Knowledge Base
(Edited)
Photo of Coleen Schmitt

Coleen Schmitt

  • 524 Points 500 badge 2x thumb
No luck, still returning the same result. Could it be something with needing to the http:// in the rich text formula? 

using google.com as an example the URL field is returning http://www.google.com, but the rich text field is only returning www.google.com 


I tested it per your comment - looks like you do need the https:// in front in order for Quick Base to not interpret it as a link to itself. Maybe add something like 

var text urlH = if( not contains([URL Field]),"https://" & [URL Field],[URL Field]);

Then use that $urlH in place of [URL field] in your <a> tag. Depending on your workflow - you might always consider throwing a target='_blank' in your <a> - this way it opens this link in a new tab instead of the same window - unless that is the intent. 

So: <a href='urltarget='_blank'>Link Text</a>

Chayce Duncan | Director of Strategic Solutions
(720) 739-1406 | chayceduncan@quandarycg.com
Quandary Knowledge Base
Photo of Coleen Schmitt

Coleen Schmitt

  • 524 Points 500 badge 2x thumb
Even when I use a var text to add the http:// before the URL i'm still getting same error (QB does not recognize the link) which is frustrating because the link is the exact same to what is showing in the URL field (as seen in screenshot below). 

The only way that seems to actually be working is when i type the exact URL into the a=href formula (ie. var text URL="<a href=' "www.google.com"'&"; '>"&$URLWords&"</a>"; Unfortunately that wont work for me since the URL is always going to be different. 

any other ideas? If not i have appreciated your help and speedy responses regardless!  



Photo of Adam Keever

Adam Keever

  • 1,684 Points 1k badge 2x thumb
Do you need to use ToText() for your URL field so that is interpreted in the rich text field?
Photo of Coleen Schmitt

Coleen Schmitt

  • 524 Points 500 badge 2x thumb
tried that too. No luck :/
Photo of Jordan McAlister

Jordan McAlister

  • 1,360 Points 1k badge 2x thumb
Have tried the approach of doing the same thing through dynamic form rules?
If the file is attached, show a formula-text field with your message and hide URL field, then if not, show your URL field and hide the text field.
Photo of Coleen Schmitt

Coleen Schmitt

  • 524 Points 500 badge 2x thumb
Unfortunately this field is meant to live on a report and in an email notification which is why the Form Rules won't work in this scenario. Thank you for the suggestion though!
Take a look at this post - specifically the very very last comment presented by Coach. Him and I had a back and forth on a somewhat similar topic - and I remember him now mentioning that there are realm settings that is a bit off the beaten path to find that can limit your ability to redirect or open external links
https://community.quickbase.com/quickbase/topics/edit-a-record-and-redirect-to-an-outside-website


Chayce Duncan | Director of Strategic Solutions
(720) 739-1406 | chayceduncan@quandarycg.com
Quandary Knowledge Base
(Edited)
Yes, I’m sure that’s it. They default Realms to block external redirects and also they may default Realms to block external frames.