PnP-PowerShell icon indicating copy to clipboard operation
PnP-PowerShell copied to clipboard

Add-PnPField -Type Calculated gives error Formula can't be empty

Open jagrock opened this issue 8 years ago • 4 comments

###Notice: many issues / bugs reported are actually related to the PnP Core Library which is used behind the scenes. Consider carefully where to report an issue:###

  1. Are you using Apply-SPOProvisioningTemplate or Get-SPOProvisioningTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/officedev/PnP-Sites-Core/issues.
  2. Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
  3. If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/OfficeDev/PnP-PowerShell/tree/master/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/officedev/PnP-Sites-Core/issues

Reporting an Issue or Missing Feature

Expecting to be able to add a Calculated Field to a list. When type set to Calculated, you get an error that the -Formula paramenter cannot be empty. This is not a valid parameter. It

Expected behavior

New field added with type of Calculated. Ability to set the formula in the New-PnPField.

Actual behavior

Error that a parameter is empty, but parameter does not exist. It creates the field as Text instead of Calculated

image

Steps to reproduce behavior

$fldName = "Control Operation Name Test" $fldInternalName = $fldName -replace " ", ""

Add-PnPField -List $pnpList -DisplayName $fldName -InternalName $fldInternalName -Type Calculated -AddToDefaultView

Which version of the PnP-PowerShell Cmdlets are you using?

  • [ ] PnP PowerShell for SharePoint 2013
  • [ ] PnP PowerShell for SharePoint 2016
  • [x] PnP PowerShell for SharePoint Online

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

(you can retrieve this by executing Get-Module -Name *pnppowershell* -ListAvailable) 2.22.1801.0

How did you install the PnP-PowerShell Cmdlets?

  • [ ] MSI Installed downloaded from GitHub
  • [x] Installed through the PowerShell Gallery with Install-Module
  • [ ] Other means

jagrock avatar Feb 02 '18 22:02 jagrock

Thank you for reporting this.

We added this functionality in the March 2018 release of PnP PowerShell. If you specify the type as Calculated you will notice there will be an additional parameter available called Formula.

erwinvanhunen avatar Mar 07 '18 22:03 erwinvanhunen

Formula parameter now available, but it throws errors on any input. Issue https://github.com/SharePoint/PnP-PowerShell/issues/1488 was raised for this by another user.

jagrock avatar Apr 11 '18 18:04 jagrock

I have just downloaded the latest version on PnP and we still get an error "Add-PnPField : Formula can't be empty."

This is the code we are using Add-PnPField -List $NewList -Type Calculated -Formula "=[Title]" -DisplayName "Test" -InternalName "Test"

Zerg00s avatar Oct 04 '18 21:10 Zerg00s

Hi, i had the same problem. And I remove from my .xml tempalate some words. Before: =[{fieldtitle:Cislo][{fieldtitle:Cislo]. After: =[Cislo][Cislo]. Then it works, with no problem.

I do it because, when I develope my source site, i used SPD. And in template.xml i had the same name in the "DisplayName", and in "Name". So maybe there was problem, because it need internalName of the field. When I create list columns using schema.xml, I used internalName in the element .

Maybe this ist not correct way how to do it. Maybe there will be good to use ID of the source field of calculated column.

tomasgazsi avatar Feb 08 '19 12:02 tomasgazsi