Sharepoint List lookup does not link to document as expected, instead it links to page about document

Nederman, Josefin 1 Reputation point
2021-03-11T09:33:45.7+00:00

I have a List with a lookup column, looking up documents. I expected the items in the column to link to the document itself, but instead they link to som sort of "about page" for the document in question. Is there a way to achieve what I was expecting? That is: - A list with items that refer to and use the title of documents in a sharepoint directory AND link directly to this document

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,628 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Echo Du_MSFT 17,116 Reputation points
    2021-03-12T07:14:02.723+00:00

    Hello @Nederman, Josefin ,

    As SharePoint does not support to hyperlink value as Lookup field. So, it is not possible to use Lookup column to link directly to the file itself.

    Thanks,
    Echo Du

    =================

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Arijit_cloud 1 Reputation point Microsoft Employee
    2021-03-14T03:59:16.807+00:00

    Hi,
    As EchoDu mentioned, it is not possible out of the box as by design lookup column links to display form of the item being looked up, in your case the document display form.

    However there is a way to get past this and achieve the functionality using Json Column formatting.

    • Set up the document library Title/Any other custom text column data with the document name with extension. example- the value should be something like "ABC Documents.pdf"
    • In the list where you use lookup, look up to this column -
    • Use JSON fomatting on the lookup column,
      HOW TO REFERENCE
    • Verify the functionality

    Here is some json code I was trying out in my environment,

    {  
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",  
      "elmType": "a",  
      "txtContent": "@currentField.lookupValue",  
      "attributes": {  
        "target": "_blank",  
        "href": "='https://abctenant.sharepoint.com/sites/Demo/Shared%20Documents/' + @currentField.lookupValue"  
      }  
    }  
    

    @currentField.lookupValue will get the text value from lookup library.


  3. Nathan Field 1 Reputation point
    2022-10-27T11:32:27.38+00:00
    0 comments No comments