cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sasrsc1966
Resolver I
Resolver I

hyperlinks from rich text field in sharepoint list not working

I've read some threads on this. I have a Rich Text column in SP that contains zero or more hyperlinks. 
In this example there's 2 links...
The one to cnn works and the one to the specific file fails (which is pointing to a SP document library).
It seems external links work but internal links are failing. Why?
sentence.jpg
This is the Run History - pull of the item...

 

"RTE": "<div class=\"ExternalClass7056347710B048FBA4F9BD11A7A26FD4\"><div><span style=\"color&#58;black;\">​So some text goes <strong>here</strong>. Link to <a href=\"/&#58;b&#58;/r/sites/CorporateTravelUSPrivate/Shared%20Documents/BCP%2010NOV21%20(2).pdf?csf=1&amp;web=1&amp;e=JV0YZR\">specific file</a> in a SP document library. Here's a link to <a href=\"https&#58;//www.cnn.com/\">cnn</a>.&#160;</span></div></div>",

 

So how would I go through the entire RTE variable and locate any instance of 
/&#58;b&#58;/r/sites
and replace it with ...
https://xxxoffice365.sharepoint.com/sites

 There could be more than one link that needs fixing. 


1 ACCEPTED SOLUTION

Accepted Solutions

My final workaround was this.
1) Initialize a string variable for my tenant 

https://xxxoffice365.sharepoint.com/sites/

2) Initialize an array of "bad prefixes"

createArray('/&#58;x&#58;/r','/:b:/r','/&#58;b&#58;/r')

3) Use the replace function to replace /sites/ with the correct string tenant #1

replace(items('Apply_to_each')?['RTE'],'/sites/',variables('ReplaceWithThisUrl'))

4) Loop through the array of bad prefixes (that I've found - and I assume this list will grow). Item() refers to the item I'm looping through and here I replace it with "" 

replace(outputs('Compose'),item(),'')

 5) Now I can email the output of #4 and it seems to work. What an ugly hack and why Microsoft ?????????
Surely there is a better way? and why is it happening in the first place?

View solution in original post

3 REPLIES 3
sasrsc1966
Resolver I
Resolver I

"RTE": "<div class=\"ExternalClassD5056302194342169D4F9796AA4A9F70\"><ul><li>Hyperlink to <a href=\"/sites/CorporateTravelUSPrivate\">SP</a>.</li><li>Hyperlink to another <a href=\"/&#58;x&#58;/r/sites/csdtest/BarbTesst/Menus%20for%20Venues/PNC%20Suite%20Order%20Form.xlsx?d=w750956669a9f4ef8a7edb70c877f0213&amp;csf=1&amp;web=1&amp;e=oyCflN\">SP file</a>.</li><li>Hyperlink to <a href=\"https&#58;//powerusers.microsoft.com/t5/Building-Power-Apps/Links-to-SharePoint-from-PowerApp-not-working/td-p/412439\">external site</a>.</li><li>Hyperlink to <a href=\"/sites/csdtest/BarbTesst/Lists/Instructions/AllItems.aspx\">another SP location</a>.</li></ul></div>",

I could fix the original issue as explained with a compose on that RTE field.

replace(items('Apply_to_each')?['RTE'],'/&#58;b&#58;/r/sites/','https://xxxoffice365.sharepoint.com/sites/')

I thought I was done, but then I added multiple links to test out that and you can see the SP List is reading 4 links in this larger version. #1, 2, and 4 need fixing... and the system recorded them as different links.

  1. /sites/CorporateTravelUSPrivate 
  2. /&#58;x&#58;/r/sites/csdtest
  3. https&#58;//powerusers.microsoft.com - this one is good...
  4. /sites/csdtest/

In 1,2,4 /sites/ must be replaced by https://xxxoffice365.sharepoint.com/sites/ so how can I do that?


After getting my answer I'd love to know ...

1) why is this an issue when external links seem to work

2) is it only internal SP pages where this issue exists

3) why isn't this bug fixed... it seems it's been around since it all began.

  1.  

My final workaround was this.
1) Initialize a string variable for my tenant 

https://xxxoffice365.sharepoint.com/sites/

2) Initialize an array of "bad prefixes"

createArray('/&#58;x&#58;/r','/:b:/r','/&#58;b&#58;/r')

3) Use the replace function to replace /sites/ with the correct string tenant #1

replace(items('Apply_to_each')?['RTE'],'/sites/',variables('ReplaceWithThisUrl'))

4) Loop through the array of bad prefixes (that I've found - and I assume this list will grow). Item() refers to the item I'm looping through and here I replace it with "" 

replace(outputs('Compose'),item(),'')

 5) Now I can email the output of #4 and it seems to work. What an ugly hack and why Microsoft ?????????
Surely there is a better way? and why is it happening in the first place?

sasrsc1966
Resolver I
Resolver I

I haven't accepted my own solution as I want to share this with others but I would love to know any better solutions.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (3,863)