1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.