0

So, I created a custom list named "Events" and one named "attendees" for an event-management-solution (lets call it attendee training) in a site-collection at my SP2010 Server.

My Problem: I want to create a "register" custom-action (ribbon) for every event in the DispForm of the Events-List, so attendees could register (= add an entry to the attendee list with username (loginName()) and event id) with a click on the button. The Ribbon should show only in this listform, not for every custom list - listform in the site collection.

So far so good, I found this question here: Show custom action in ribbon for only one list and it seems logical to me.

My 'real' Problem (apart from not exactly knowing how to create the ribbon in VS2010, but I think I can figure that out): I want to check if the user is already registered for the event (= into the attendees list), and if he/she is registered, there should not be the "register" action, instead it should appear an "unregister" action.

So now I have no idea how to change the custom ribbon depending on this scenario and hope you could help me.

Best regards, Dominik

2 Answers 2

1
<CustomAction Id="Ribbon.ListForm.Display.Register" RegistrationId="101"   RegistrationType="List" Location="CommandUI.Ribbon" Rights="EditListItems" >
<CommandUIExtension>
  <CommandUIDefinitions>
    <CommandUIDefinition Location="Ribbon.ListForm.Display.Actions.Controls._children" >
      <Button Id="Ribbon.ListForm.Display.Actions.RegisterButton"
        Alt="Register"
        Sequence="10"
        LabelText="Register"
        ToolTipTitle="Register"
        ToolTipDescription="Registers for event"
        Image32by32="/_layouts/1033/images/formatmap32x32.png" Image32by32Top="-128" Image32by32Left="-448"
        Command="Command.Register"
        TemplateAlias="o1" />
    </CommandUIDefinition>
  </CommandUIDefinitions>
  <CommandUIHandlers>
    <CommandUIHandler
                Command="Command.Register"
                CommandAction="javascript:Register();"
                EnabledScript="javascript:isRegistered();" />
  </CommandUIHandlers>
</CommandUIExtension>

I would use the Sharepoint client object model to get the current item to do the checks for the isRegistered function and the same for the register function.

Important to note is the RegistrationId. That is the list type, in this case 101 (document library) which must correspond to the base list template identifier of the list. In your case you would change the registration type in the custom action to 'ContentType' and the RegistrationId to the content type ID of your event content type.

1
  • Thank you. This is the correct answer I think but I'm going with visual web parts and buttons for now. :)
    – Dominik
    Dec 4, 2012 at 11:19
0

I think that you need to create ribbon component. See this post for details. If you look at section

Step 3.3: Add Methods to Tell the Ribbon Manager What Commands This Page Component Handles, and How and When to Handle Commands

you can find an example how to set your ribbon is available\unavailable state. I hope it helps you to move in right direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.