Document hyperlink from document properties

Copper Contributor

Do you have any ideas to create a Hyperlink from document properties in modern view as it is in classic view? See examples below

 

Modern mode:

Anders_Poulsen_RG_0-1718365102173.png

Classic mode:

Anders_Poulsen_RG_1-1718365193087.png

 

 

4 Replies

@NicolasKheirallah thank you very much

 

I am able to create a link in the header but i can not get a dynamic href link to the current document. (see json below the picture)

 

The current href returns: https://royalgreenland.sharepoint.com/sites/BusinessProcessModel/sites/Test%20af%20brugerdefineret%2...

 

And I want it to return:  

https://royalgreenland.sharepoint.com/sites/BusinessProcessModel/Test%20af%20brugerdefineret%20visni... 

 

Anders_Poulsen_RG_0-1720682831145.png

 

{
"elmType": "div",
"attributes": {
"class": "ms-borderColor-neutralTertiary"
},
"style": {
"width": "99%",
"border-top-width": "0px",
"border-bottom-width": "1px",
"border-left-width": "0px",
"border-right-width": "0px",
"border-style": "solid",
"margin-bottom": "16px"
},
"children": [
{
"elmType": "div",
"style": {
"display": "flex",
"box-sizing": "border-box",
"align-items": "center"
},
"children": [
{
"elmType": "div",
"attributes": {
"iconName": "link",
"class": "ms-fontSize-42 ms-fontWeight-regular ms-fontColor-themePrimary",
"title": "Details"
},
"style": {
"flex": "none",
"padding": "0px",
"padding-left": "0px",
"height": "36px"
}
}
]
},
{
"elmType": "div",
"attributes": {
"class": "ms-fontColor-neutralSecondary ms-fontWeight-bold ms-fontSize-24"
},
"style": {
"box-sizing": "border-box",
"width": "100%",
"text-align": "left",
"padding": "21px 12px",
"overflow": "hidden"
},
"children": [
{
"elmType": "a",
"txtContent": "Click here for details",
"attributes": {
"href": "= @currentWeb + '/sites/Test%20af%20brugerdefineret%20visning/Forms/AllItems.aspx?ID=' + [$ID] ",
"target": "_blank"
}
}
]
}
]
}

 

You need to use $FileLeafRef BUT there's a bug where it returns 0/blank...

Thanks for response. We have created a URL column and a workflow to fulfill this link when new files is created or updated.