in

Dot Net Mafia

Group site for developer blogs dealing with (usually) .NET, SharePoint 2013, SharePoint 2010, Office 365, SharePoint Online, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog

Syndication

Archives

Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for SharePoint 2013, Office 365 / SharePoint Online and Visual Studio 2013.

Creating SharePoint Ribbon Custom Actions with Visual Studio 2012

Let’s face it.  In SharePoint 2010, creating ribbon custom actions was not a very pleasant experience.  You had to know the inner workings of the XML and the black-magic behind selecting the right Id in the CommandUIDefinition.  We had community tools like CKSDEV to help though.  Now, I am happy to see that a new Ribbon Custom Action SharePoint Project Item slipped into Preview 2 of the Office Developer Tools.  This new SPI provides a nice wizard interface to guide you through the process of creating an action.  Let’s take a look at it.

First, you’ll need to create a new SharePoint App project.  The downside of the tool is that it is only available for SharePoint apps.  It’s not in regular SharePoint 2013 projects.  In my example today, I am going to attach a custom action to a list item to take the user back to the default.aspx application page.  Of course, you can use traditional techniques as before to add JavaScript, pass parameters, and whatever else you need to do.  I just want to show you what the wizard looks like today.

In the Add New Item menu, you’ll see the new wizard here.  Choose Ribbon Custom Action and give it a name.

RibbonCustomActionSPI

Note, that there is also a new Menu Item Custom Action template as well.  When you click Add, you will be taken to the next step in the Wizard.  Here you first need to choose whether you will apply this to the Host Web or the App Web.  Remember that the App Web that has all of the pieces of your app and the Host Web is the site that hosts an instance of your app.  One way you might use this new feature is that a user clicks on an item in the host web, uses the ribbon action and gets redirected to your app.

You have the ability to bind the custom action to a list template or a list instance.  If Host Web is selected, selecting List Instance will provide you with a list of all instance on the particular host web that your app is currently configured to publish to.  Otherwise, if you choose List Template, it will provide you a list of common templates.  I don’t think the Wizard will let you pick a custom template, so you would probably have to edit the XML manually when you are done.

CustomRibbonActionWizardHostWebListTemplate

In my case, I have chosen App Web and then a specific List Instance.  It knows to look through the List Instances you have in your project and put them in the list.

CustomRibbonActionWizardAppWebListInstance

When you continue to the next step, it will allow you to specify the location of the ribbon, the text to display, and what page the user should be redirected to when clicking the link.  You can select any existing ASP.NET page in the project for the action to navigate to.  If you want to execute JavaScript instead, you would need to edit the XML once you complete the wizard.

RibbonCustomActionWizardStep2

It provides you with a list of locations that the control can be located at:

RibbonCustomActionWizardStep2ControlLocation

When you are finished, Visual Studio generates the XML that you need.  You can make edits as necessary.  However, at this point there is no going back to the Wizard and making changes.  If you want the Wizard again, you’ll have to delete the item and recreate it.

RibbonCustomActionXml

At this point we can run the project and go to the list that we set the action on.  Selecting the list item, will expose the action in the ribbon.

RibbonCustomActionVisibleOnList

Clicking on the Ribbon Action, I then get redirected to my app home page.

RibbonCustomActionDefault

I’m pretty excited about this feature since I have always struggled with creating custom actions.  I think this will make it much easier to create actions now.  This is important because this is one of the key ways to link between the host web and the app web.  Unfortunately, this action is only present in Apps, but you could always cut and paste it into another project.  You could also likely take the code it generates and use it in your SharePoint 2010 projects as well.

Comments

 

Creating SharePoint Ribbon Custom Actions with Visual Studio 2012 - Corey Roth [MVP] | SharePoint Resources | Scoop.it said:

Pingback from  Creating SharePoint Ribbon Custom Actions with Visual Studio 2012 - Corey Roth [MVP] | SharePoint Resources | Scoop.it

December 15, 2012 4:44 AM
 

My SharePoint links December 18, 2012 | Jeremy Thake's musingsJeremy Thake's musings said:

Pingback from  My SharePoint links December 18, 2012 | Jeremy Thake's musingsJeremy Thake's musings

December 18, 2012 12:16 PM
 

Blog del CIIN said:

Una de las posibilidades a nivel de desarrollo que tenemos en el nuevo modelo de aplicaciones de SharePoint

February 22, 2013 3:00 AM
 

SharePoint 2013: Creación de acciones personalizadas en el contexto de una aplicación (I)! « Pasi??n por la tecnolog??a… said:

Pingback from  SharePoint 2013: Creación de acciones personalizadas en el contexto de una aplicación (I)! « Pasi??n por la tecnolog??a…

February 22, 2013 3:04 AM
 

Blog de la vista previa de Office 365 said:

Una de las posibilidades a nivel de desarrollo que tenemos en el nuevo modelo de aplicaciones de SharePoint

February 22, 2013 3:08 AM
 

Blog técnico de Office 365 said:

Una de las posibilidades a nivel de desarrollo que tenemos en el nuevo modelo de aplicaciones de SharePoint

February 27, 2013 2:41 PM
 

ribbon custom action template in visual studio 12 | Question and Answer said:

Pingback from  ribbon custom action template in visual studio 12 | Question and Answer

November 22, 2013 5:00 AM
 

Enable Custom Actions in every Document Library (SharePoint 2013) | DL-UAT said:

Pingback from  Enable Custom Actions in every Document Library (SharePoint 2013) | DL-UAT

May 18, 2015 6:53 AM

Leave a Comment

(required)  
(optional)
(required)  
Add

About CoreyRoth

Corey Roth is an independent SharePoint consultant specializing in ECM, Apps, and Search.
2015 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems