powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG] Set-PnPView -Aggrations: Count # is not displayed after activating an aggregation

Open till-llit opened this issue 1 year ago • 3 comments

Reporting an Issue or Missing Feature

trying to activate "count" aggregations on SharePoint Lists and Libraries is not working properly.

Expected behavior

The count of items should be displayed in the UI after activating it.

Actual behavior

Only the "Count" placeholder is visible without the actual number of items

Steps to reproduce behavior

Set-PnPView -List "Site Pages" -Identity "All Pages" -Aggregations "<FieldRef Name='LinkFilename' Type='COUNT'/>"

Additional Info:

With Export-PNPListToSiteTemplate i can see the missing part in the list schema

Activate aggregation in UI:

<Aggregations Value="On"> <FieldRef Name="LinkFilename" Type="COUNT" /> </Aggregations>

Activate aggregation with PnP Powershell:

<Aggregations Value="Off"> <FieldRef Name="LinkFilename" Type="COUNT" /> </Aggregations>

As you can see the "Value" property of the Aggregations is still set to "Off" after activation - this might be the root cause.

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

2.99.41

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

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

till-llit avatar Jan 27 '25 10:01 till-llit

Workaround: instead of using Set-PnPView it is possible to activate count in views with the following workaround:

$view = Get-PnPView -List "SitePages" -Identity "All Pages" -Includes Aggregations,AggregationsStatus $view.Aggregations = '<FieldRef Name="LinkFilename" Type="COUNT" />' $view.AggregationsStatus = 'On' $view.Update() Invoke-PnPQuery

With this script we can set the missing AggregationStatus to "On" manually.

till-llit avatar Jan 27 '25 13:01 till-llit

I opened a PR to fix this issue

jackpoz avatar Apr 20 '25 15:04 jackpoz

hey @till-llit , this issue has been fixed and will be available in tomorrow's nightly builds. Thanks for raising the issue, much appreciated !

gautamdsheth avatar Apr 20 '25 18:04 gautamdsheth