pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
987 stars 665 forks source link

Unable to apply view formatting to modern lists #2241

Closed joaoferreira closed 4 years ago

joaoferreira commented 4 years ago

I'm unable to automate the application of a view formatting using a JSON file. The JSON is valid and when added through the UI works without issues. I'e tried to apply it through a custom xml template and using the cmdlet Set-PnPView -List $listName -Identity $viewName -Values @{CustomFormatter = $listViewFormattingJSON.ToString()}

On both scenarios got the same error. The template was copied from the gallery of templates available on github and can be found here.

Actual behavior

When trying to apply it I'm getting the error Name cannot begin with the '=' character, hexadecimal value 0x3D I was not able top find the cause of the issue but it's related with the bold condition below

"children": [ { "elmType": "span", "style": { "display": "=if([$Birthday] <= @now,'block','none')" }, "attributes": { "iconName": "BirthdayCake" } }

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

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

3.12.1908.1

How did you install the PnP-PowerShell Cmdlets?

ghost commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

merly-cortez commented 4 years ago

Hi, any update on this one?

bcameron1231 commented 4 years ago

Hi! I realize this is an old ticket, but noticed it was recently updated. So the error is due to having to encode the formula operators (>, < , <= , >=). In your formula, please update those with encoded values. An example: changing "<=" to "<="

"children": [
{
"elmType": "span",
"style": {
"display": "=if([$Birthday] &lt;= @now,'block','none')"
},
"attributes": {
"iconName": "BirthdayCake"
}
}

Hope this helps!