1

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>

1 Answer 1

0

You need to rebuild your application to correct DLL version for SharePoint 2019. Next is that I see in code you have bad url:

 string editProfileUrls = string.Format("~site/_layouts/15/EditProfile.aspx?UserSettingsProvider={0}&ReturnUrl={1}", Uri.EscapeDataString(usp.ProviderIdentifier.ToString()), sourceUrl);

You need to use /_layouts/16/ for SP2016 and SP2019.

There are changes between SP2013 and newer Versions, make sure your application is compatible.

3
  • Thx for your quick response. I have updated all referenced SharePoint Dlls to 16.0.0.0 and changed the path to ~site/_layouts/16/EditProfile.aspx?UserSettingsProvider={0}&ReturnUrl={1}. But behaviour is the same. On default.aspx my custom action works and I see the edit profile link in the menu bar, but not on the persons.aspx.
    – Sandro
    Jan 31, 2019 at 10:45
  • there can be also some different definitions in MaterPage, cause for SP16 and SP19 its like "OneDrive" not Mysite Jan 31, 2019 at 10:51
  • MaterPage should be the same for Person.aspx or Default.aspx. I dont understand the behaviour, because it's the same site collection???
    – Sandro
    Jan 31, 2019 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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