Forum Discussion
List Form Formatting - can't get title and hyperlink from Hyperlink column
- Aug 11, 2024
Hi grant_jenkins, You are right; the Hyperlink column value behaves differently in column formatting compared to form formatting.
Fortunately, you can use the following function to retrieve Hyperlink column information in form (header or footer) formatting:
- Url
"txtContent": "=substring('[$FieldName]',0,indexOf('[$FieldName]', ','))"and title
"txtContent": "=substring('[$FieldName]',indexOf('[$LinkTest]', ',')+2,indexOf([$FieldName] + '^', '^'))"
michalkornet hello I have a similar issue - i have different URLs and Alternative text in a Hyperlink Column. In the normal list they work fine, but when I apply JSON in Format Current View the link doesnt work. It opens to about:blank.
What is missing from my code?
Thank you,
Hi LauraDaisy, could you provide the part of your View formatting code related to the URL column? I’ll try to check it promptly.
- LauraDaisySep 26, 2024Copper ContributorThankyou, this is the code I use on the row formatting.
"elmType": "a",
"attributes": {
"href": "[$Link.url]",
"target": "_blank"
},
"txtContent": "[$Link.desc]"- michalkornetSep 27, 2024Iron Contributor
Hi LauraDaisy, I checked again today, and it looks like the column formatting has started working. However, the issue with the view formatting remains the same.
You can try this sample on your environment (in my case I get empty value when I use hyperlink column) https://github.com/pnp/List-Formatting/tree/master/view-samples/menu-link-tiles
- LauraDaisySep 30, 2024Copper ContributorHi michalkornet
i'm not entirely sure what I need to do. Do I need to add column formatting AND row formatting?
- michalkornetSep 26, 2024Iron Contributor
Hi LauraDaisy, it looks like there is an issue with the Hiperlink column. I have also tried one of the sample provided on PnP Samples page, and unfortuantely I cannot see the description of the link (without any customization it works)
https://github.com/pnp/List-Formatting/tree/master/column-samples/hyperlink-display-url
when I use "txtContent": "[$Link]" is has simply a link. Let me ask on samples repository, maybe someone has the same issue.