Domanda

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

È stato utile?

Soluzione

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')"; 
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top