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

Enabling modern audience targeting from Set-PnPList does not function correctly #3783

Open
5 tasks
hawaiianmetal opened this issue Feb 23, 2024 · 3 comments
Open
5 tasks
Labels
bug Something isn't working

Comments

@hawaiianmetal
Copy link

hawaiianmetal commented Feb 23, 2024

Reporting an Issue or Missing Feature

When using the -EnableModernAudienceTargeting switch to enable modern audience targeting on a library, the configuration changes appear to be correct (e.g. new fields added), but when trying to set an audience on a new or existing item, I consistently receive this error: Invalid field name. {b1d24626-4fc1-403a-925f-9d2225c421de} /sites/xyz/_catalogs/users. My testing has been on the Site Pages library in communication sites.

I have tried this multiple times in two different tenants and with different versions of PnP.PowerShell, and I always get the same behavior. When using the GUI to turn audience targeting off and then back on, the problem goes away.

I have compared list settings with it working (using the GUI) and not-working (using PnP), and I can't find a difference. This includes all the list settings, all field settings including SchemaXml and EventReceivers. The resulting configuration matches what I see in the ListExtension.cs source code. There seems to be something else that the GUI is doing, but I can't pinpoint what it is.

Also interesting is if I turn audience targeting on by using the GUI, then turn it off using the GUI, and then turn it on again using PnP, it still works. Thus, the problem really is when turning it on using PnP when it has not already been turned on by the GUI.

Expected behavior

When using the PnP cmdlet to enable audience targeting, I expect it to work the same as if I used the GUI.

Actual behavior

Described above.

Steps to reproduce behavior

  1. Create a new communication site.
  2. Use Connect-PnPOnline to connect to new site.
  3. Set-PnPlist -Identity "Site Pages" -EnableModernAudienceTargeting $true
  4. Create a new page and try to set the Audience to a valid group.

Note: I get the same error if I try to set the Audience from the Properties or Details panel on an existing page.

See attached document Audience Targeting errors.docx for screenshots, including an animation of the error I receive. In that, I also provide the details for the request/response HTTP 500 errors the browser receives when trying to save.

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

v2.2.0 and v2.3.0

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

  • [ X ] Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify
@hawaiianmetal hawaiianmetal added the bug Something isn't working label Feb 23, 2024
@hawaiianmetal
Copy link
Author

After doing some additional testing, I've found that turning on audience targeting from the GUI on different library will also fix the the problem within Site Pages. Thus, it appears to be a site/web level setting, rather than the list. I've compared all the features, property bags and a few other site/web-level setting and can't find anything. If someone has a SharePoint Server SE install on hand, it may help to use .NET Reflector to see what the code is doing when the checkbox is enabled.

@Segelfeldt
Copy link

We can confirm the same issues as @hawaiianmetal We are running PnP PowerShell 2.4.0. Anyone have any updates regarding this issue?

@benjacernuda
Copy link

Hi all,

We have the same issue in our tenants. If we use PnP Powershell to enable audience targeting in the list

Set-PnPList -Identity "ListNmae" -EnableModernAudienceTargeting $true

these 2 fields are being created (We can see this in editing the list view):

  • $Resources:spcore,AudienceLookupField_DisplayName;
  • $Resources:spcore,AudienceUserField_DisplayName;

If we try to add an item with a value in the Audience field (this is the name of the field in the Details form: $Resources:spcore,AudienceUserField_DisplayName;) we can the same error described here:

Error: Invalid field name. {b1d24626-4fc1-403a-925f-9d2225c421de} /sites/fresh-intranet/_catalogs/users

We can see the same behaviour applying a PnP Template (schema 2022/09) EnableAudienceTargeting="true" in pnp:ListInstance

Any idea what this could be happening?

Many thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants