1

I have a requirement to add a new menu item to the selected document '...' menu.

The new item would be added to '... - more actions' or '... - open menu dialog for this selected item' menus in a Sharepoint document library.

e.g. When you select a document in a Sharepoint site, you can click the '...' link to get a menu. The menu normally shows options like 'Open, Share, Follow' and additionally has a sub-menu '...' More actions. I want to add a new menu item here. This would be added to a Sharepoint Online website (O365)

Apologies, I am not familiar with Sharepoint terminology, but it appears this would be adding a custom action to the document menu?

Can adding a new menu item be achieved through configuration of the site, or does this require an extension / app to be developed and installed for the new menu items to be added (the new item will need some custom text in the link)?

The new menu item will serve as an 'Open with MyApplication' link. This will be a link to the selected document prefixed with some custom text.

e.g. The plain link may be similar to https://mysite.sharepoint.com/sites/test/documents/mydocument.pdf

the prefix will be pre-defined static text similar to
myapplication://dummyPrefix

Combined the resulting link will look similar to myapplication://dummyPrefixhttps://mysite.sharepoint.com/sites/test/documents/mydocument.pdf

This is basically;

protocol-handler://staticprefixACTUALURL

Windows can be configured so that myapplication:// uris are handled by a specific application (protocol handler). The prefix is to help the receiving application parse the actual document URL (so it knows what type of link it's dealing with) This aspect / mechanism is already working fine, it is the customization of the Sharepoint Online website / menus that I need some help with

0

As Per my understanding, you are trying to create a custom action for the Menu Item in the ECB Menu(...). that will open a URL in the Popup.

Please find the step as below: 1) Create a Custom action for the specific Document library using the PNP CSOM. Please check the below link for the detailed code.

Custom Actions Using CSOM For SharePoint Online

string Pwd = ConfigurationManager.AppSettings["Password"].ToString();  
               string UserName = ConfigurationManager.AppSettings["Username"].ToString();  
               string spsiteurl = ConfigurationManager.AppSettings["SPSiteUrl"].ToString();  
               var secure = new SecureString();  
               foreach (char c in Pwd)  
               {  
                   secure.AppendChar(c);  
               }  
               using (var clientContext = new ClientContext(spsiteurl))  
               {  
                   clientContext.Credentials = new SharePointOnlineCredentials(UserName, secure);  
                   var customlist = clientContext.Web.Lists.GetByTitle("SampleCustomList");  
                   clientContext.Load(customlist);  
                   clientContext.ExecuteQuery();  
                   Microsoft.SharePoint.Client.UserCustomActionCollection collUserCustomAction = customlist.UserCustomActions;  
                   UserCustomAction newcustomaAction = collUserCustomAction.Add();  
                   newcustomaAction.Location = "EditControlBlock";  
                   newcustomaAction.Sequence = 100;  
                   newcustomaAction.Title = "Custom List ECB Menu";  
                   newcustomaAction.Url = "javascript:alert('Custom List ECB custom Action')";                    

                   clientContext.ExecuteQuery();  
                   lbl_Success.Text = "Custom List ECB Menu Created Successfully";  
               }  

If you want to open a page in the popup, update the url property as below.

newcustomaAction.Url = "javascript:OpenPopUpPageWithTitle('https://tenant.sharepoint.com/sites/sharepointmates/Lists/SampleCustomList/AllItems.aspx', RefreshOnDialogClose, 600, 400,'SampleCustomList')"; 
  • Thank you, that is very helpful. The edit control block menu item was terminology I was looking for. Here is an additional link that goes into detail on this topic. docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/… – plumdog Feb 15 '18 at 22:16
  • Thanks, I have been able to make a custom menu item in the ECB using an SPFX. Though I haven't been able to figure out how to get the URL for the selected document in the list. I'm going to post that as a separate question since it will be more concise – plumdog Feb 21 '18 at 22:55

Your Answer

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

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