Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add custom link to SharePoint list settings page by code

I would like to add a custom link to a SharePoint list settings page (listedit.aspx) from code, I have searched the web and Stack Overflow, and can't seem to find any examples or documentation on doing this specifically.

There are a dozen examples on how to do this from the elements.xml and on deployment/activation, but I would like to do this from C# code, like this:

SPUserCustomAction customAction = spCustomList.UserCustomActions.Add();
customAction.Url = "someurlhere";
customAction.Name = "CustomName";
customAction.Location = "Microsoft.SharePoint.ListSettings";
customAction.Title = "Custom Settings";
customAction.Update();
spCustomList.Update();
like image 563
user80130 Avatar asked Oct 09 '22 20:10

user80130


People also ask

Can you link to a specific section of a SharePoint page?

A SharePoint anchor link allows linking to a specific point or section within a piece of content on your SharePoint Online pages, enabling you to direct a reader's focus exactly where you want.


1 Answers

You are on the right track, but your Location is incorrect and you need a Group.

Try the following:

SPUserCustomAction customAction = spCustomList.UserCustomActions.Add();
customAction.Url = "someurlhere";
customAction.Name = "CustomName";
customAction.Location = "Microsoft.SharePoint.ListEdit";
customAction.Group = "GeneralSettings";
customAction.Title = "Custom Settings";
customAction.Update();

For more information on Locations, see Default Custom Action Locations and IDs.

like image 187
Rich Bennema Avatar answered Oct 13 '22 10:10

Rich Bennema