Button to open attached PDF document in sharepoint list

Ramon03 1 Reputation point
2021-07-26T10:37:39.497+00:00

Hello everyone, I would like to know if it is possible to create a button in the sharepoint list using JSON column formatting, and the function of this button would be to open the pdf document that is attached to the item, I have a template below that I use to edit or delete the item .

117951-img.jpg

Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Allen Xu_MSFT 13,861 Reputation points
    2021-07-27T02:33:40.083+00:00

    Hi @Ramon03 ,

    I'm afraid it is not supported to to create a button in the list using JSON column formatting to open attachements in SharePoint Online.

    When using Button elements in your JSON code, Button elements can be used to launch a specific action on the parent item. Every button element has a required property, customRowAction, that specifies an action that's taken when the button is clicked. This action must be one of the following values:

    • defaultClick
    • share
    • delete
    • editProps
    • openContextMenu
    • executeFlow

    Please take a reference to this article and the article contains detailed description of the function of each value: button elements. The action property is set as below in the JSON formatting code of the delete button.

    "customRowAction": {  
        "action": "delete"  
      }  
    

    However, the action values such as opening attachments are not provided currently. As a result, it is impossible to open the attachment via a button using JSON formatting. As an alternative, you can build your SharePoint Framework (SPFx) Extensions to inject CSS/JS code to the list to achieve your requirement.


    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.