0

I am trying to create a column in a document library that contains multiple hyperlinks.

Unfortunately it's not possible to have a rich text column in a Document library (unless I'm missing something?). So I need to use plain text I guess?

It would be great if the hyperlink pulls from another column, however I can also just work with hrefs as static text as well, but I can't find anything about formatting a column to display multiple hyperlinks, for example some sort of split function based on a semicolon?

Appreciate your help.

1
  • 1
    @GaneshSanap FANTASTIC this is it!!! Thank you SO MUCH! Commented Aug 12, 2023 at 6:34

1 Answer 1

1

You can achieve it using SharePoint online JSON formatting capabilities.

You have to use the hyperlinks and it's display text in plain multiple lines of text column in this format:

[Microsoft 365 & Power Platform Community]https://pnp.github.io/ [Sharing Is Caring]https://pnp.github.io/sharing-is-caring/ [M365 Platform & Power Platform Community Recognition Program]https://pnp.github.io/recognitionprogram/ 

Then use below column formatting JSON for your column:

{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "style": { "display": "flex", "align-items": "flex-start", "justify-content": "space-between", "padding": "4px 0" }, "children": [ { "elmType": "div", "style": { "display": "=if(@currentField=='','none','flex')", "flex-direction": "column", "align-items": "flex-start" }, "children": [ { "elmType": "a", "forEach": "listItem in split(@currentField,'[')", "txtContent": "=substring([$listItem],0,indexOf([$listItem],']'))", "style": { "margin-bottom": "1px", "display": "=if([$listItem]=='','none','')", "padding": "2px 15px", "border-radius": "15px", "text-decoration": "none", "font-size": "14px" }, "attributes": { "class": "ms-bgColor-themeLighter ms-bgColor-themeLight--hover ms-fontColor-neutralPrimaryAlt ms-fontColor-themePrimary--hover", "href": "=replaceAll(substring([$listItem],indexOf([$listItem],']')+1,indexOf([$listItem]+'^','^')),'\n','')", "target": "_blank" } } ] }, { "elmType": "span", "customRowAction": { "action": "editProps" }, "attributes": { "iconName": "Edit", "class": "ms-fontSize-s ms-bgColor-themeLight ms-bgColor-neutralTertiary--hover" }, "style": { "display": "inline-block", "cursor": "pointer", "margin": "0 5px", "padding": "4px", "border-radius": "100px" } } ] } 

Output:

enter image description here

Source: Multiple hyperlinks in single field

Remember to use the internal name of columns in JSON formatting wherever required. You can get the internal name of your columns by following this article: How to find the Internal name of columns in SharePoint Online?


Here's another JSON sample which might help you: Multi-Choice Links

enter image description here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.