Skip to content

[BUG] AudienceIds not working after running Add-PnPNavigationNode #2708

@kbeeveer46

Description

@kbeeveer46

Reporting an Issue or Missing Feature

Issue

Expected behavior

Please let me know if this isn't the right place for this question/bug report. When I run the following code (see below) to add a Quick Launch link and add an audience it seems to work just fine. No errors are thrown and when I go to the SharePoint site I can see the audience associated with the guid was added to the link.

The problem is that the Quick Launch link is still visible to me even though I am not part of the audience. I was expecting the link to be hidden. Even more strange is that if I add the audience to the link using the UI on the SharePoint site it works as expected. The link is hidden from me.

Is there something I'm not doing correctly? All the websites I can find online say this code should work.

Almost 4 years ago someone had the same issue: https://sharepoint.stackexchange.com/questions/260831/how-to-set-navigationnode-audienceids

We cannot automate any of our sites because of this. We're forced manually rename a Quick Launch item in the SharePoint UI and click Save and then edit it again and rename it back to what it was. Why does triggering the Save in the SharePoint UI make the audiences work but not PnP?

Actual behavior

Here is a screen shot. The Audience Test 9 link should not be visible to me because I am not in that group. Even after refreshing the page it is still visible.
image

Steps to reproduce behavior

$newNode = Add-PnPNavigationNode -Location "QuickLaunch" -Title "Audience Test" -Url "http://linkless.header/"

$audienceList = New-Object System.Collections.Generic.List[guid]
$audienceList.add([System.guid]::New(("7e5c22f2-1254-453e-84f4-58ce4ed3e995")))

$newNode.AudienceIds = $audienceList
$newNode.Update()
Invoke-PnPQuery

What is the version of the Cmdlet module you are running?

1.11.0

Which operating system/environment are you running PnP PowerShell on?

  • [X ] Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions