Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I set Audiences to target on Navigation Link #1065

Closed
jansenbe opened this issue Jan 5, 2023 Discussed in #1064 · 2 comments
Closed

How do I set Audiences to target on Navigation Link #1065

jansenbe opened this issue Jan 5, 2023 Discussed in #1064 · 2 comments
Assignees
Labels
area: model 📐 Related to the core SDK models help wanted Extra attention is needed

Comments

@jansenbe
Copy link
Contributor

jansenbe commented Jan 5, 2023

Discussed in #1064

Originally posted by khinklenj December 21, 2022
How do I set Audiences to target on Navigation Link in code.

image

image

@jansenbe jansenbe added help wanted Extra attention is needed area: model 📐 Related to the core SDK models labels Jan 5, 2023
@jansenbe jansenbe self-assigned this Jan 10, 2023
@jansenbe
Copy link
Contributor Author

@khinklenj: I've just committed a change that enables you to specify the needed audiences when creating or updating navigation nodes. This code will appear in the next nightly build (version 1.8.66 or higher), docs will come but in the meantime check below code to learn how to use this new feature:

// Ensure audience targeting is enabled for navigation nodes
context.Web.EnsureProperties(w => w.NavAudienceTargetingEnabled);
context.Web.NavAudienceTargetingEnabled = true;
context.Web.Update();

parentNode = await context.Web.Navigation.QuickLaunch.AddAsync(
  new NavigationNodeOptions
  {
      Title = "Parent Node",
      Url = context.Uri.AbsoluteUri,
      AudienceIds = new System.Collections.Generic.List<Guid> { context.Site.GroupId }
  });

I'll close this issue, feel free to open a new one in case you can't get things to work. Thanks for using PnP Core SDK!

@jansenbe
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: model 📐 Related to the core SDK models help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant