0

I want to add some CustomActions to a document library. I tried to follow this description:

https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/modern-experience-customizations-customize-lists-and-libraries#editcontrolblock-user-custom-actions

I have tried it with a Team and a Communicationsite, NoScript should be disabled by "Allow users to run custom script on [] sites" in the SharePoint admin center. In each there is a document library called 'foo'.

The Script runs with no error, but also with no (visible) result. What am i doing wrong?

Edit:

As requested the XML and the Powershellscript. Didn't integrated it earlier, because it's, except from the url and the path, the same as in the documentation

XML

<pnp:ProvisioningTemplate ID="EditControlBlockSamples" Version="1" xmlns:pnp="http://schemas.dev.office.com/PnP/2015/12/ProvisioningSchema">
  <pnp:CustomActions>
    <pnp:SiteCustomActions>
      <pnp:CustomAction Name="CA_1" Description="ca 1" Location="EditControlBlock" RegistrationType="List" RegistrationId="101" Title="CA 1 Title" Sequence="3000" Url="https://contoso.azurewebsites.net/pages/index.aspx" Enabled="true"/>
      <pnp:CustomAction Name="CA_2" Description="ca 2" Location="EditControlBlock" RegistrationType="ContentType" RegistrationId="0x0101" Title="CA 2 Title" Sequence="4000" Url="https://contoso.azurewebsites.net/pages/index.aspx" Enabled="true"/>
    </pnp:SiteCustomActions>
  </pnp:CustomActions>
</pnp:ProvisioningTemplate>

Powershell

# Connect to a previously created Modern Site
$cred = Get-Credential
Connect-PnPOnline -Url https://[tenant].sharepoint.com/sites/[mysiteurl] -Credentials $cred

# Apply the PnP provisioning template
Apply-PnPProvisioningTemplate -Path c:\[my_path_to_xml] -Handlers CustomActions

Edit2:

I've read somewhere, that i might have some old librarys, so i deinstalled and installed newer one with

Uninstall-Module -Name SharePointPnPPowerShellOnline -AllVersions -Force
Install-Module -Name PnP.PowerShell

But i now just need to use Invoke-PnPSiteTemplate (see 'Changes' under https://pnp.github.io/powershell/articles/upgrading.html) and it's still not working.

4
  • You edit your question and post xml file details. Commented Oct 4, 2022 at 13:13
  • ok...i edited it... Commented Oct 4, 2022 at 13:41
  • is this - Url="contoso.azurewebsites.net/pages/index.aspx" is live? Commented Oct 4, 2022 at 14:55
  • no, but just in case i just changed it to https://google.com and it still don't work Commented Oct 4, 2022 at 15:00

1 Answer 1

0

Ok, found the solution, the error was in the given xml from the documentation. xmlns:pnp="http://schemas.dev.office.com/PnP/2015/12/ProvisioningSchema" needs to be xmlns:pnp="http://schemas.dev.office.com/PnP/2019/09/ProvisioningSchema" For some reasons, you will only the 'CA 1 Title', 'CA 2 Title' (the two custom actions from the xml) will be hidden..

But, I found a better way

$url = "https://[my_tenant].sharepoint.com/sites/[my_site]"
Connect-PnPOnline -Url $url -Credentials $cred

Add-PnPCustomAction -Name 'Test 1' -Title 'Test 1' -Description 'Test 1' -Group 'SiteActions'-RegistrationType 'List' -RegistrationId '101' -Location 'EditControlBlock' -Sequence 3010 -Url 'https://www.google.com'

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.