Replies: 1 comment 1 reply
-
Nothing? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello dear PNP Community,
I have a strange side-effect and I am not sure if this is a issue in the pnp module or the wrong way of me implementing it.
So I try to describe my situation and context.
What I am trying to do is setting the target audience of a link inside my hub navigation. I try to achive this with the following code:
` $url ="https://xxx.sharepoint.com/sites/SiteName"
$title = "New Link9"
$linkUrl = "https://XXX.de"
$audienceId = New-Object System.Collections.Generic.List[guid]
$audienceId.add([System.guid]::New("b62fbbef-5c3b-45ac-987f-755474006bce"))
Connect-PnPOnline -Url $url -Credentials $Cred
#$ctx = Get-PnPConnection
$context = Get-PnPContext
$newNode = Add-PnPNavigationNode -Location TopNavigationBar -Title $title -Url $linkUrl
$newNode.AudienceIds = $audienceId
$newNode.Update()
$context.ExecuteQuery()`
The problem is, that the code is run without any errors and the navigation seems to be extended with the added link and target audience. But when I visit the site the target audience is not working. I can still see the link even if I am not a member of the target audience.
The interessting part is that when I press the "edit" button of the top bar na
vigation, I can see all the links and target audiences in the left bar editor, but the target audience is not applied.
When I change something in the edit panel (eg. a new link or chang
es to a link) and save it the target audience is applied and all works. But it works only when I use the SharePoint GUI and somehow its not working via code.
Can anybody help me out with this problem?
Beta Was this translation helpful? Give feedback.
All reactions