In SharePoint 2016, the <Mapping> element allowed you to specify a URL to be invoked when clicking on a file name based on file extensions. What is the recommended replacement in SharePoint 2019/2021 to achieve similar functionality?

PratikSavla 25 Reputation points
2024-09-16T13:43:32.85+00:00

The <Mapping> element in SharePoint 2016 allowed the configuration of custom actions, such as invoking a URL when a user clicked on a file name, based on the file’s extension. This feature is no longer available in SharePoint 2019. What is the correct approach to replicate this behavior in SharePoint 2019? https://learn.microsoft.com/en-us/sharepoint/dev/schema/mapping-element

SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,616 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Ling Zhou_MSFT 17,705 Reputation points Microsoft Vendor
    2024-09-17T08:15:55.24+00:00

    Hi @PratikSavla,

    Thank you for posting in this community.

    Are you using the Microsoft SharePoint Foundation Software Development Kit (SDK)?

    Unfortunately, we can't find an alternative to the Mapping element, because SharePoint Server 2019 doesn't support Microsoft SharePoint Foundation Software Development Kit (SDK) anymore.

    Instead, Microsoft recommends using SharePoint Framework (SPFx) extensions to replicate this behavior in the "modern" UI. SPFx extensions provide similar functionality to the SharePoint Feature Framework's CustomAction capability. The most useful option in this context is the Application Customizer extension, which allows developers to extend the native "modern" UI of SharePoint by adding custom HTML elements and client-side code to pre-defined placeholders of "modern" pages.

    For more information on SPFx extensions, see the "Migrating from UserCustomAction to SharePoint Framework extensions" and "Differences between SharePoint Framework solutions and SharePoint Feature Framework customizations" articles in the SharePoint Dev Center.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.


  2. PratikSavla 25 Reputation points
    2024-09-17T11:28:01.91+00:00

    Hi @Ling Zhou_MSFT

    Thank you for your response.

    While using SPFx extensions could address the issue for the Modern UI, this solution would only work for that specific interface. However, we are currently using a SharePoint solution with multiple features built inside, and we also need to retain this functionality in the Classic UI.

    Could you provide guidance on how to achieve similar functionality in the Classic UI since SPFx doesn't cover this scenario?

    Thank you!

    0 comments No comments

  3. Ling Zhou_MSFT 17,705 Reputation points Microsoft Vendor
    2024-09-18T02:51:40.84+00:00

    Hi @PratikSavla,

    I'm sorry, my previous answer didn't solve your problem.

    I consulted the relevant information, the classic interface we can use script editor web part instead of the mapping element. We can add our HTML, CSS, JS code to implement our custom functionality.

    The web part is designed to add scripts inside a web part page in SharePoint 2013/2016/2019. We can also add HTML content into a script editor web part in SharePoint.

    1.Before you can use this Webpat you need to activate two functions.

    • Make sure the site collection feature “SharePoint Server Publishing Infrastructure” is activated.
    • Make sure the site feature “SharePoint Server Publishing” is activated.

    2.Add a SharePoint Script Editor Web Part:

    • To add a script editor web part, make sure you have permission to edit the SharePoint page. Sometimes if you are working on a subsite, even if you are an owner of the subsite, you will not see the web part categories while editing the page.
    • To add a script editor web part, create the SharePoint web part page first, then from the Ribbon click on INSERT -> Web Part -> then from the categories select Media and Content and then choose Script Editor web part as shown in the fig below: User's image
    • Once you add the script editor web part into the SharePoint web part page, you can see the EDIT SNIPPET button. Then click on the EDIT SNIPPET and add the following JavaScript code. User's image

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.