I have a problem with a custom action in SharePoint 2019 on premise. The custom action adds a link in the menu item of the SharePoint menu bar. It's a mysite collection.
SharePoint 2013 (it works): https://ibb.co/PxM0wzP
In SharePoint 2019 theres no link (site collection feature is deployed) see here: https://ibb.co/bRtkQXw
The crazy thing is that's not visible on the Person.aspx. On the default.aspx it's added: https://ibb.co/XW2qh4h
It's working fine on the old 2013 on premise SharePoint. I have no idea why it's not added to the person.aspx
Here's the code for the custom action class:
public class EditProfileCustomLink : SPSecurityTrimmedControl
{
protected MenuItemTemplate menuItem;
protected override void CreateChildControls()
{
base.CreateChildControls();
SPUser currentuser = SPContext.Current.Web.CurrentUser;
SPWebApplication webApplication = SPContext.Current.Site.WebApplication;
if (currentuser != null && webApplication != null && webApplication.UserSettingsProvider != null )
{
try
{
// Get the assigned settings provide
SPUserSettingsProvider usp = webApplication.UserSettingsProvider;
// Get the source url
string sourceUrl = SPContext.Current.Site.MakeFullUrl(HttpContext.Current.Request.RawUrl.ToString());
sourceUrl = SPHttpUtility.HtmlEncode(DeltaPage.RemoveDeltaQueryParameters(sourceUrl));
string editProfileUrls = string.Format("~site/_layouts/15/EditProfile.aspx?UserSettingsProvider={0}&ReturnUrl={1}", Uri.EscapeDataString(usp.ProviderIdentifier.ToString()), sourceUrl);
// Initialize the menu item
this.menuItem = new MenuItemTemplate();
this.menuItem.Title = SPUtility.GetLocalizedString("$Resources:EditProfile", Constants.ResourceFile, (uint)CultureInfo.CurrentUICulture.LCID);
this.menuItem.Text = SPUtility.GetLocalizedString("$Resources:EditProfile", Constants.ResourceFile, (uint)CultureInfo.CurrentUICulture.LCID);
this.menuItem.Description = SPUtility.GetLocalizedString("$Resources:EditProfile", Constants.ResourceFile, (uint)CultureInfo.CurrentUICulture.LCID);
this.menuItem.Sequence = 1040;
this.menuItem.Visible = true;
this.menuItem.ClientOnClickNavigateUrl = editProfileUrls;
// Add custom menu item
this.Controls.Add(menuItem);
}
catch (Exception ex)
{
Logger.Instance.LogError(LogCategory.Web, String.Format("Error while creating edit profile link '{0}'", ex));
}
}
}
}
The elements.xml:
<CustomAction
Id="29F3F98A-5338-41A3-BFAD-ECEED235873D"
GroupId="PersonalActions"
Location="Microsoft.SharePoint.StandardMenu"
ControlAssembly="$SharePoint.Project.AssemblyFullName$"
ControlClass="Brose.ProfileDisplay.Source.EditProfileCustomLink">
</CustomAction>