-
Notifications
You must be signed in to change notification settings - Fork 395
Description
Reporting an Issue or Missing Feature
Reporting a regression where Add-PnPField fails to add an existing Calculated Site Column to a list (specifically a calculated column dependent on the 'Document ID' field). While this operation completes successfully via the SharePoint UI, the PnP command now fails.
This script logic, which we use for provisioning each newly created site, functioned correctly for over a year and started failing approximately 2 months ago.
### Expected behavior
When executing Add-PnPField -List -Field , I expect the cmdlet to successfully add the existing site column to the library, automatically resolving the dependency on the Document ID field, just as the SharePoint UI does.
### Actual behavior
The command fails with an error when attempting to add the column.
Error message: "An error occurred while adding the site column 'COLUMNNAME ' to library 'LIBRARY NAME': The formula contains a syntax error or is not supported."
Observation: The issue seems specific to Calculated Columns referencing the Document ID. The cmdlet appears unable to validate the formula context during the add operation (likely due to the Document ID dependency not being resolved yet), whereas the UI handles this correctly.
### Steps to reproduce behavior
- Activate Document-id-service on site level (_layouts/15/ManageFeatures.aspx?Scope=Site)
- At the site collection level: Create a Calculated Site Column (e.g. named "TESTBUG") which includes the Value Document ID
- Run a PnP PowerShell script to add this existing column to the library. The last line will cause the error.
$siteUrl = "https://[tenant].sharepoint.com/sites/[site]"
$listName = "Documents"
$columnName = "TESTBUG"
Connect-PnPOnline -Url $siteUrl -Interactive
# This command now fails (Regression):
Add-PnPField -List $listName -Field $columnName
- Notice manually adding the column to a library via the UI works fine.
###Workarounds Attempted
To isolate the issue, we attempted several alternative implementation methods, but all resulted in the same failure:
- XML Provisioning (Add-PnPFieldFromXml): We attempted to add the field using its full XML schema definition.
- Content Type Approach (Add-PnPFieldToContentType): We attempted to add the field directly to the list's Content Type instead of the list itself.
- Object-based Approach: We first retrieved the site column object using Get-PnPField and passed the object to the -Field parameter (instead of the string name) to ensure the correct ID/Context was used.
None of these methods succeeded. This strongly suggests the issue lies in the underlying validation logic for Calculated Columns referencing Document ID during the provisioning phase.
What is the version of the Cmdlet module you are running?
PowerShell-7.2 PnP.PowerShell 2.12.0
Microsoft.Online.SharePoint.PowerShell 16.0.24713.12007
Which operating system/environment are you running PnP PowerShell on?
- Azure Runbooks