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();
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With