Published: 2 November 2017
Custom user actions are the commands, which are available for the user access at different locations within SharePoint.These custom actions can come up at any location within SharePoint like ribbon view, site settings page, ECB menu etc: It can be an icon/text, which implements a functionality such as navigating to a landing page, starting a Workflow on an item and so on. All the icons, which come up in the list view ribbon are the examples of custom actions. In many scenarios, we might want to add custom business functionality as a custom user action for ease of access.
After the application of the JSOM code, we will have an extra custom action in the ribbon as shown below that will show the list id when clicked.This has been tested in both SharePoint 2016 and Office 365.
Let’s see, how we can do the same programmatically, using JSOM.
The complete code used for the demo is given below :
The above code will be saved as a txt file and can be uploaded to the site assets library of SharePoint. Append “?toolpaneview=2” at the end of the List View URL to go to the edit mode of the page. Add a Content Editor Webpart and refer the uploaded text file.
Going back to the list, we can see that the custom action has come up in the Ribbon, as shown below:
On Clicking the new custom action in the ribbon, we can see it in action.The custom action gives is the ID of the current list. Similarly we can add other custom business logic which will be executed upon clicking this custom action.
Priyaranjan is a SharePoint Consultant and Microsoft MVP with 10 years experience in developing and deploying SharePoint Applications.He has worked on various SharePoint iterations starting from MOSS 2007 through SharePoint 2016 and Office 365. He is a frequent contributor at Microsoft TechNet and has won 33 Gold Medals in various TechNet Wiki Guru Monthly Competitions.As a token of appreciation for the TechNet community activities, he was interviewed by Microsoft Program Manager,Ed Price. He has also published 300 Articles and 4 SharePoint Ebooks in different technical communities.You can find his Microsoft TechNet contributions here