sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

Custom Action Locations

Open pgodwin opened this issue 2 years ago • 2 comments

Documentation states that NewFormToolbar is a valid location (along with several reference books), however when deploying it to SharePoint online it states that the location is invalid.

Elements.xml:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="965225e0-662b-4089-acdc-78433528f646.TestMenuAction"
                RegistrationType="List"
                RegistrationId="{$ListId:Lists/Add-in List Test;}"
                Location="NewFormToolbar"
                Sequence="10"
                Title="Search Patients">
    <!-- 
    Update the Url below to the page you want the custom action to use.
    Start the URL with the token ~remoteAppUrl if the page is in the
    associated web project, use ~appWebUrl if page is in the app project.
    -->
    <UrlAction Url="~appWebUrl/Pages/LookupWebPart.aspx?{StandardTokens}&amp;SPListItemId={ItemId}&amp;SPListId={ListId}" />
  </CustomAction>
</Elements>

Error:

  @"Error 1
        CorrelationId: 817f7325-e9bc-41da-ae9f-400b459ce1cf
        ErrorDetail: There were problems with the app web definition in the package.
        ErrorType: App
        ErrorTypeName: App Related
        ExceptionMessage: Deployment failed in host web https://<redacted>.sharepoint.com/sites/dev.addin for app <redacted>/ca27c77f-c56f-409d-a69d-7064091fdda4. Microsoft.SharePoint.SPException: Feature definition with Id ca27c77f-c56f-409d-a69d-7064091fdda5 failed validation, file '/elements33b5f3d1-0607-455b-b292-880b39ec127d.xml', line 6, character 17: The 'Location' attribute is invalid - The value 'NewFormToolbar' is invalid according to its datatype 'http://schemas.microsoft.com/sharepoint/:CustomActionLocations' - The Enumeration constraint failed.

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

pgodwin avatar Jul 14 '22 07:07 pgodwin

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ghost avatar Jul 14 '22 07:07 ghost

According to the schema there are only two supported locations:

  • CommandUI.Ribbon
  • EditControlBlock

This also means the documentation on https://docs.microsoft.com/en-us/sharepoint/dev/schema/customaction-element is incorrect (and countless printed books on this topic!).

Was this a recent change for SPO, or just a limitation on AppHosted features? Should the documentation be updated to reflect this?

EDIT: looks like some of this has been documented on https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/sharepoint-add-ins-ux-design-guidelines#adding-custom-actions-to-the-host-web

pgodwin avatar Jul 18 '22 22:07 pgodwin