none
Custom Action CommandUIDefinition Location for Calendar All Events and Current Events Views RRS feed

  • Question

  • I am trying to create a custom Action for Ribbon Menu for calendar list for SharePoint using CSOM. I am able to create custom action for the calendar view Successfully with the below code, I am trying to implement the same for the All Events view and Current Events and changed the Location attribute for the CommandUIDefinition tag with different values as mentioned in the Msdn link Customization Locations

    var SourceList = destinationContext.Web.Lists.GetByTitle(Listnameitem);
                        destinationContext.Load(SourceList);
                        destinationContext.ExecuteQuery();
                        Microsoft.SharePoint.Client.UserCustomActionCollection collUserCustomAction = SourceList.UserCustomActions;
                        Microsoft.SharePoint.Client.UserCustomAction RemoveRibbonaction = collUserCustomAction.Add();
                        RemoveRibbonaction.Location = "CommandUI.Ribbon.ListView";
                        RemoveRibbonaction.Sequence = 10002;
                        RemoveRibbonaction.Title = "RemoveDocuments";
                        location = "<CommandUIDefinition Location=\"Ribbon.Calendar.Events.Share.Controls._children\">";
                        //location = "<CommandUIDefinition Location=\"Ribbon.Items.Actions.Share._children\">";
                        //location = "<CommandUIDefinition Location=\"Ribbon.ListItem.Share._children\">";
                        string RemoveDocumentRibbonActionurl = "https://www.google.co.in/";
                        RemoveRibbonaction.CommandUIExtension = @"<CommandUIExtension><CommandUIDefinitions>"
                        + location
                        + "<Button Id=\"InvokeAction.Button1\" TemplateAlias=\"o1\" Command=\"EditFormButtonCommand1\" CommandType=\"General\" LabelText=\"RemoveDocuments\" Image32by32=\"_layouts/15/images/placeholder32x32.png\" Image16by16=\"_layouts/15/images/placeholder16x16.png\" />"
                        + "</CommandUIDefinition>"
                        + "</CommandUIDefinitions>"
                        + "<CommandUIHandlers>"
                        + "<CommandUIHandler Command =\"EditFormButtonCommand1\" CommandAction = \"javascript:OpenPopUpPageWithTitle('" + RemoveDocumentRibbonActionurl + "', RefreshOnDialogClose, 600, 400,'Remove Documents');\"  EnabledScript=\"javascript: SP.ListOperation.Selection.getSelectedItems().length >= 1\" /> "
                        + "</CommandUIHandlers></CommandUIExtension>";
                        RemoveRibbonaction.Update();
                        destinationContext.Load(SourceList, list => list.UserCustomActions);
                        destinationContext.ExecuteQuery();

    I Would like to know the value for the location attribute for The All Events view and Current Events View. I tried with Ribbon.Items.Actions.Share._children and Ribbon.Items.Actions.Share._children values but unable to create custom action in the mentioned views

    Can anyone help me on this.



    TARUN

    Thursday, March 16, 2017 9:28 AM

Answers

  • Hi,

    You could try this.

    var SourceList = destinationContext.Web.Lists.GetByTitle("Calendar2");
                    destinationContext.Load(SourceList);
                    destinationContext.ExecuteQuery();
                    Microsoft.SharePoint.Client.UserCustomActionCollection collUserCustomAction = SourceList.UserCustomActions;
                    Microsoft.SharePoint.Client.UserCustomAction RemoveRibbonaction = collUserCustomAction.Add();
                    RemoveRibbonaction.Location = "CommandUI.Ribbon";
                    RemoveRibbonaction.Sequence = 10002;
                    RemoveRibbonaction.Title = "RemoveDocuments";
                    string location = "<CommandUIDefinition Location=\"Ribbon.ListItem.Actions.Controls._children\">";                
                    //location = "<CommandUIDefinition Location=\"Ribbon.Items.Actions.Share._children\">";
                    //location = "<CommandUIDefinition Location=\"Ribbon.ListItem.Share._children\">";
                    string RemoveDocumentRibbonActionurl = "https://www.google.co.in/";
                    RemoveRibbonaction.CommandUIExtension = @"<CommandUIExtension><CommandUIDefinitions>"
                    + location
                    + "<Button Id=\"InvokeAction.Button333332\" TemplateAlias=\"o1\" Command=\"EditFormButtonCommand1\" CommandType=\"General\" LabelText=\"RemoveDocuments\" Image32by32=\"_layouts/15/images/placeholder32x32.png\" Image16by16=\"_layouts/15/images/placeholder16x16.png\" />"
                    + "</CommandUIDefinition>"
                    + "</CommandUIDefinitions>"
                    + "<CommandUIHandlers>"
                    + "<CommandUIHandler Command =\"EditFormButtonCommand1\" CommandAction = \"javascript:OpenPopUpPageWithTitle('" + RemoveDocumentRibbonActionurl + "', RefreshOnDialogClose, 600, 400,'Remove Documents');\"  EnabledScript=\"javascript: SP.ListOperation.Selection.getSelectedItems().length >= 1\" /> "
                    + "</CommandUIHandlers></CommandUIExtension>";
                    RemoveRibbonaction.Update();
                    destinationContext.Load(SourceList, list => list.UserCustomActions);
                    destinationContext.ExecuteQuery();

    You could compare the default action definitions for more details.

    C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\GLOBAL\XML

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, March 17, 2017 7:05 AM