Advertisements

Combining Multiple CustomAction Elements Together

I’ve been slowly, but surely, getting the questions asked during my SharePoint Saturday Boston presentation, so, here goes the next one.

Can you combine multiple custom actions within a feature?

YES! You sure can! In my 4th demonstration (Custom Action Groups), I showed this within my ElementManifest file (manifest.xml), where I defined a CustomActionGroup, as well as 4 additional CustomAction elements within a single manifest file. See code example below:

   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   3:   <CustomActionGroup Id="HelpResources"
   4:        Location="Microsoft.SharePoint.SiteSettings"
   5:        Title="CustomAction Resources on MSDN" />
   6:  
   7:   <CustomAction Id="CustomActionLocsAndIds" 
   8:                 Title="Custom Action Locations and Ids" 
   9:                 GroupId="HelpResources" 
  10:                 Location="Microsoft.SharePoint.SiteSettings" 
  11:                 Sequence="0">
  12:     <UrlAction Url="http://msdn.microsoft.com/en-us/library/bb802730.aspx"/>
  13:   </CustomAction>
  14:   
  15:   <CustomAction Id="CustomActionElement"
  16:                 Title="CustomAction Element"
  17:                 GroupId="HelpResources"
  18:                 Location="Microsoft.SharePoint.SiteSettings"
  19:                 Sequence="1">
  20:     <UrlAction Url="http://msdn.microsoft.com/en-us/library/ms460194.aspx"/>
  21:   </CustomAction>
  22:   
  23:   <CustomAction Id="CustomActionGroupElement"
  24:                 Title="CustomActionGroup Element"
  25:                 GroupId="HelpResources"
  26:                 Location="Microsoft.SharePoint.SiteSettings"
  27:                 Sequence="2">
  28:     <UrlAction Url="http://msdn.microsoft.com/en-us/library/ms438085.aspx"/>
  29:   </CustomAction>
  30:  
  31:   <CustomAction Id="HideCustomAction"
  32:                 Title="HideCustomAction Element"
  33:                 GroupId="HelpResources"
  34:                 Location="Microsoft.SharePoint.SiteSettings"
  35:                 Sequence="3">
  36:     <UrlAction Url="http://msdn.microsoft.com/en-us/library/ms414790.aspx"/>
  37:   </CustomAction>
  38: </Elements>

The person who asked this question had a business need to create a lot of custom actions, however, did not want to have a feature built for each one, even though features are handy ways of deploying functionality to SharePoint, if you have hundreds of features, that can become a management nightmare.

I also mentioned, that what you can do is separate these out into functional ElementManifest files – as you can have any number of them defined in your feature, and they do not all need to be named elements.xml, or manifest.xml. A good example of this can be seen in the 12 Hive FEATURES folder, looking at some of the built in CustomAction elements and CustomActionGroup elements.

For instance, if you wanted to break out your manifest definition files into one for each CustomActionGroup, you can do so easily, by specifying different files – code example below.

   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <Feature xmlns="http://schemas.microsoft.com/sharepoint/"
   3:          Id="{FFC864FD-C78D-4fd0-8F18-963D1EA59E0C}"
   4:          Title="SPS.CustomActionGroup"
   5:          Description="Custom Action Grouping example"
   6:          Scope="Site"
   7:          Version="1.0.0.0"
   8:          Hidden="false"
   9:          >
  10:   <ElementManifests>
  11:     <ElementManifest Location="MSDNResources.xml"/>
  12:     <ElementManifest Location="BlogResources.xml"/>
  13:     <ElementManifest Location="TwitterResources.xml"/>
  14:   </ElementManifests>
  15: </Feature>

 

This will make not only the management of features easier within SharePoint as far as managing what gets activated, also the management of the solution as well, so you are not managing 400 CustomAction elements within a single file, you can break them out as needed.

And to answer the question before it gets asked in this entry’s comments – the CustomActionGroup does not need to be defined within the same file as its CustomAction elements. You could break it down into CustomActionGroups.xml and CustomActions.xml if you’d like to separate them out.

Again – the names of the ElementManifest XML definition files do not matter – as long as they are referenced within the feature.xml file (this filename MUST be feature.xml), then you are all set. They really do not even need to have an XML definition, as long as it is declared at the top of the XML file, they will be interpreted as XML files.

 

Advertisements

RecurrenceId Attribute of the CustomAction Element

During my session at SharePoint Saturday Boston – I mentioned that I would look into just what exactly RecurrenceId does, and make a post about it here. RecurrenceId is a token that is available for the URLAction element within the CustomAction element.

I did some additional research, and was able to find this via MSDN:

“A recurrence identifier that identifies a specific instance of a recurring appointment. It is used with the to uniquely identify the instance.”

The above quote is from an Exchange related article, however, it still fits the bill, and gives a little more useful information than the one found in the RecurrenceId Property link below, which is:

Returns the identifier (ID) of an instance of a recurrent item.

Paul Grenier (AutoSponge) who was attending my session, was spot on with his guess. The RecurrenceId property would be useful in the URLAction element to specifically identify a recurring event list item, and to only act on that specific item, as recurring events within events lists are just one single list item, and not copies of the original with their own specific GUIDs. They have the same GUID as the original event, however, just have an incremented RecurrenceId that can be used to directly identify that specific occurrence of the event.

More information on this SPListItem Property can be found here in the WSS 3.0 SDK: SPListItem.RecurrenceID Property (Microsoft.SharePoint), however, there is not much there.

As of my session on Saturday, I had never needed to use this attribute before in my travels, and virtually the only documentation on it I could find before SharePoint Saturday Boston, was that you cannot use it with the Edit Control Block. This doesn’t make much sense to me however, why it is even available, as I would think the only time this would be useful, is to directly interact with an event list item from the Edit Control Block.

image

Anyhow – there is now a blog posting out in the wild for others to consume regarding the RecurrenceId attribute. I hope this helps someone else out.

 

CustomAction Development Resources for SharePoint

A common development task is building out custom actions for SharePoint. What is a custom action you ask? Per Microsoft: “A custom action represents a link, toolbar button, menu item, or any control that can be added to a toolbar or menu that a user sees. Custom actions can be bound to list type, content type, file type, or programmatic identifier (ProgID).” (source)

A good example of a custom action feature in SharePoint is a recently released project to CodePlex – GraceHunt.SharePoint.Features.SiteActionsRecycleBin, which adds a link to the Site Actions menu on any site collection it is activated in, to provide a link to the recycle bin of the current site.

The reasoning behind this post was to list a few great resources which help in building custom actions for SharePoint.

John Holliday has a great (sortable and exportable to excel) list of all of the custom action identifiers, available here: http://johnholliday.net/resources/customactions.html, which lists the Id, GroupId, Location, Sequence, RegistrationType and RegistrationId of all of the Custom Actions built into SharePoint.

You can also build custom action features to hide elements within SharePoint menus, toolbars, and link menus. John Holliday has a great article on locating custom action identifiers to allow you figure out how to find the identifiers for installed custom actions within SharePoint, available here: http://johnholliday.net/post/2007/10/28/How-to-find-lt3bCustomActiongt3b-identifiers.aspx

This can also be useful to assist in figuring out the sequence number for installing your custom action feature in SharePoint, so you can insert it before or after other items that are currently there.

And last, but certainly not least, MSDN has some excellent resources regarding custom actions

I hope this is useful information, and if you have any resources that should be added here, just leave a comment below, and I will add it to the list.

 

[Updated 1.28.09]
Over at SharePointDevWiki.com, there is a growing amount of information regarding custom actions.

Jan Tielens has a good article on Adding Breadcrumb Navigation to Application Pages in SharePoint Central Administration.

André Vala wrote a great post about CustomActions as well, including some great in-depth information on each of the attributes and rights for actions in his post SharePoint 2007 Deployment: Custom Action Features

 

Presentations from SharePoint Saturday New Orleans 3/24/12

Yes a month late… but, hey, it’s been a busy month!

Had a grand time in New Orleans – a well put on event as always, that I was happy to be a part of, in one of the greatest cities in the world.

http://www.sharepointsaturday.org/neworleans

Below are my two presentations from the event.

Planning and Configuring Extranets in SharePoint 2010

 

Creating Custom Actions in SharePoint 2010

Presentation and Resources from 12/14/11 FCSPUG

imageIt was earlier this year when I spoke with Bill Nagle of K2 about getting a user group up and running in Fairfield, CT. After many months later of successful meetings, I was happy to be able to go down and present to the group. The meetings themselves are hosted at Bigelow Tea, which was an interesting place – great facility, and the air smelled like tea 🙂 They even gave me a variety box of teas for coming down – I fully intend to enjoy it all!

Thanks again to Bill Nagle of K2 for spearheading the group there, Bigelow Tea for hosting the meeting, traffic for not being terrible (it’s about a ~6 hour round trip to Fairfield), Travel America for their awesome rest stops, and last, but certainly not least, everyone who came out for the meeting!

Below are my slides (minimal) from the meeting, as well as a link to the SPBasePermissions enumeration PDF I mentioned, as well as a link to Eric Kraus’s blog post with the PowerShell script to display all Custom Actions within the farm.

Please let me know if you have any questions or comments on the material in the comments below!

SPBasePermissions class enumeration PDF: http://go.gvaro.net/SPBasePerms

Erik Kraus’s PowerShell Script to list all Custom Actions in a Farm: http://blogs.msdn.com/b/ekraus/archive/2010/05/03/list-all-customactions-in-the-farm.aspx

Getting DLLs OUT of your non-managed code SharePoint solutions in Visual Studio 2010

Ever notice, that no matter what you package in Visual Studio 2010, even if it is a no-code solution? See the output of a build from a CustomAction below.

—— Build started: Project: Test.SharePoint.Features.MyCustomAction, Configuration: Debug Any CPU ——
  Test.SharePoint.Features.MyCustomAction -> c:\DevProjects\Test.SharePoint.Features.MyCustomAction\Test.SharePoint.Features.MyCustomAction\bin\Debug\Test.SharePoint.Features.MyCustomAction.dll
  Successfully created package at: c:\DevProjects\Test.SharePoint.Features.MyCustomAction\Test.SharePoint.Features.MyCustomAction\bin\Debug\Test.SharePoint.Features.MyCustomAction.wsp
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

There is a simple solution to this. Click on your project within the Solution Explorer in Visual Studio. And then below, or, wherever you have your Properties window, just change Include Assembly in Package to false. Then go ahead and re-package your solution. That was easy, eh?

image

SPTechCon 2011 San Francisco Recap and Slides

M5
 
Need I say more? I had never been out to San Francisco before, so, I had a couple of chances to get out and explore the city. Knocking off the following on my trip:
  • M5 Industries (Mythbusters!)
  • The Winchester Mystery House
  • Fisherman’s Wharf
  • The Golden Gate Bridge
  • Marin Headlands
    • WWII-era forts
  • Lombard Street
  • Alcatraz
Oh right, and also, there was this SharePoint Technology Conference going on. SPTechCon San Francisco was a great conference. Kudos to the BZ Media Team again for putting on one heck of a show!
 
I had a great time meeting new speakers, vendors, and attendees, as well as catching up with old friends, as well as go to a few great sessions.
 
A big thank you needs to go out to SPTechCon for having me there, as well as to all of the attendees of my sessions. Thank you for coming and hearing what I had to say, as well as hopefully learning a thing or two.
 
Below are my decks (WordPress does not incorporate these too good from slideshare, so please follow the links) from both of my sessions.

 

Just Freakin’ Work! Overcoming Hurdles and Avoiding Pain – Co-Presented with Mark Rackley

 

Creating Custom Actions in SharePoint 2010

 
Any questions or comments on the material from the conference – as well as any feedback from the session (please!), please leave it in the comments!

SharePoint Saturday Hartford Recap and Session Materials

altI was pleasantly surprised when about a week or so before SharePoint Saturday Hartford came around on January 29th, to hear the news that the event had sold out! We have had lots of success with SharePoint Saturday Boston, however, I was unsure if this was going to be overkill for the region, if it would all be SPS Boston attendees looking for their “fix” between our 6-8 month cycle there of events, I honestly was not sure what to expect, but, wanted to help get it going anyways, so I offered up Grace Hunt to sponsor the event.

And what a great event it was! Over 150 people attended, plus speakers and sponsors, which, by the size of the venue, was a perfect amount to fit in there comfortably. I made some great new connections with speakers and attendees alike, and had a chance to spend some time with some old friends.

165538_10150133897807642_612892641_8214470_4415448_nI presented two sessions at this event, and also helped out in our vendor-led session at lunch time.

My first session of the day was on “Creating Custom Actions in SharePoint 2010”. I had a great group in the room, which asked some very good questions, and even dealt fine with the State Service in one of my demonstrations was broken, so I could not complete a custom action running a workflow (sorry about that!)

Thank you to all my attendees for that session, and even more importantly, having some fans of the Hartford Whalers in there. Below is my slide deck from my Custom Actions presentation.

My next session was done with Tim Farrell, also of Grace Hunt. We presented “Building a Custom Solution from the Ground Up” Since Tim did most of the heavy lifting in this session – I’ll refer to his blog for the session materials (Permalink to SPS-Hartford Presentation pt1 – The Beginning).

A big thanks to SB Chattergee, Talbott Crowell, Pradeepa Siva, and Bob Ohlheiser for putting together this great event, all of the attendees and sponsors of SharePoint Saturday Hartford, and the Grace Hunt team that made it to the event!

Slides from SharePoint Saturday EMEA 2011 Presentation

Although it happened quite early for me in the morning yesterday (January 22st, 2011), SharePoint Saturday EMEA was a great event to be a part of. Although it lacked some of the main aspects I love at SharePoint Saturdays, such as networking, meeting new people, interacting with the crowd, etc., it was kind of nice to wake up, slug down a few cups of coffee, and present my session.

The EMEA team did a great job of managing this virtual SharePoint Saturday, and I hope to be able to present at future sessions. A big thanks to the attendees of my session, as well as the team that put the event together:

  • Mark Miller (@eusp)
  • Toni Frankola (@ToniFrankola)
  • Isaac Stith (@MrIsaac)
  • Ayman El-Hattab (@aymanelhattab)
  • Natasha Felshman (@TeamEUSP)

 

Below is a copy of my slide deck from the presentation. Any questions on any of the material, please leave a comment below!

Create a Custom Action to Satisfy Your “All People” Needs.

image

Thanks for the intro Carl! Much obliged! Well, in your SharePoint world, your “Pale Blue Dot” view of all of the people in your site collection is the “All People” view, you know, the User Information List.

Almost two months ago, I wrote an article on how the “All People” link in SharePoint 2010 is, well, it’s gone MIA. It is easy to get to via  link. And, if you’ve got one site collection to manage, well, its as simple as adding a link somewhere, like in a link list within a management site somewhere, or, up in the handy dandy bookmarking feature, in those fancy things all the kids are using these days, “web browsers”… whatever that means…? Anyways. So, you need to get there, but, wouldn’t it be nice and simple to add in a link to say, I don’t know, the Site Settings page? Wow! That’d be cool! Then I can access it with all of the other Users and Permissions links! Right in one place?! WOW!

image

So, the question becomes, how can we get it there? (HINT: I mentioned it in the title of this article!)

Ok, so I gave it away, shame on me, I spoiled the ending. Boo hoo. Yes, Custom Actions! That’s how we’ll get it there!

So, what to do? Well, not too much actually. The creation of Custom Actions in SharePoint 2010 and with Visual Studio 2010 has become, well, easy. Extremely easy in fact due to the fine folks who created the CKS:DEV project over at Codeplex. Why? Well, because it contains item types with fancy pants wizards to allow you to click a few buttons, and create a custom action project with ease. You really do not even need to be a developer to do this, it’s quite easy, and hey, I provide screenshots and code. Go ahead, do it!

So, let’s get started, shall we? Oh, you need a glass of water first. No problem. I’ll be here waiting for you.

… 15 minutes to get a glass of water? seriously? Did you pump it from the well?

Ok, so, make sure you have VS 2010 installed, as well as CKS:DEV. NO, I am not waiting this time. You lollygagged around with getting a glass of water last time… You had your chance!

 

First, create a new project in Visual Studio 2010

image

Then, create an Empty SharePoint Project
image

Oh, guess what you’re about to witness? Yes, you in the back in the Charlie Brown polo shirt! You’ve got it. The creation of my next codeplex project for Grace-Hunt (yes, I know, it’s been a while!)

And since we do not need to elevate privileges, or any of that fancy stuff required for a server-side deployment, we’re going to create this as a Sandboxed Solution…

image

Next, once our project is loaded in the Visual Studio IDE, let’s add a new item to the project.

image

Right click on your project, go down to Add, then select  New Item.

On the next screen you are presented with, make sure you have SharePoint and 2010 selected under Installed Templates.

image

Select Custom Action, and give it a name (such as UserInfoList). Then click Add.

Now, again, thanks to the fine folks who created CKS:DEV, we have wizards!

image

On the first screen on the wizard, we have 6 settings we are going to make use of, detail from here for each of these attributes: http://msdn.microsoft.com/en-us/library/ms460194.aspx

ID

Attribute

Description

1

Id

Optional Text. Specifies a unique identifier for the custom action. The ID may be a GUID, or it may be a unique term, for example, "HtmlViewer".

2

Title

Required Text. Specifies the end-user description for this action.

3

Description

Optional Text. Specifies a longer description for the action that is exposed as a tooltip or sub-description for the action.

4

GroupId

Optional Text. Identifies an action group that contains the action, for example, "SiteManagement". If it is contained within a custom action group, the value of the GroupId attribute must equal the group ID of the CustomActionGroup element.

For a list of the default custom action group IDs that are used in Microsoft SharePoint Foundation, see Default Custom Action Locations and IDs.

5

Location

Optional Text. Specifies the location of this custom action, for example, "Microsoft.SharePoint.SiteSettings".

If the CustomAction element contains a CommandUIExtension child element, the Location must start with "CommandUI.Ribbon". For a list of default locations that are used with the Server ribbon, see Default Server Ribbon Customization Locations.

If the custom action is a menu item or toolbar button, the possible options include EditControlBlock, NewFormToolbar, DisplayFormToolbar, and EditFormToolbar.

If it is contained within a custom action group, the value of the Location attribute must equal the location of the CustomActionGroup element.

For a list of the default custom action locations that are used in SharePoint Foundation, see Default Custom Action Locations and IDs.

6

Sequence

Optional Integer. Specifies the ordering priority for actions.

 

image

On the next page, we do not actually need to set this option, however, I wanted to, to showcase this functionality. This utilizes the SPBasePermissions class to show whether this can be viewed to the user, based on the permissions they have for this object, in this case, the site collection.

image

On the last screen, and this is the important part, we need to specify the URL we want to have our CustomAction link to, this is the URLAction element. The ~sitecollection is a Token. More information on what tokens can be used in a URLAction can be found on slide #30 of my Creating Custom Actions in SharePoint presentation.

image

Now that we’ve finished defining the custom action, we just have a couple of more things to do. Since we do not our feature to be called “Feature1”, right-click on Feature1 in the Solution Explorer, and choose Rename.

image

Type it in, hit enter, all good.

Next we want to remove Feature 1 from after the title of our feature. Double click on the UserInfoList feature we just renamed, and we get a designer view of our feature (new in VS 2010).

image

In the Title field, remove Feature 1 after our feature, and add a description. Also, change the scope from Web to Site, which means we will deploy our solution to the site collection. Which also means, this link will appear for all Users and Permissions sections throughout all of the site settings pages within our site collection.

image

Now for the money! Right click on the project and select Deploy.

image

Look at the output window to see if we had success or failure…

image

And now look at your site settings page – there is our new link!

And that’s it! I will have this project published to Codeplex within the next few days, so, please keep an eye out.

%d bloggers like this: