pnp / powershell

PnP PowerShell
https://pnp.github.io/powershell
MIT License
662 stars 343 forks source link

Invoke-PnPBatch language problem #806

Closed paoIpao closed 2 years ago

paoIpao commented 3 years ago

When execute Invoke-PnPBatch after add-pnplistitem I have some problem with the language for number value, it's seems that I need use local language and pass number with comma for decimal, while if I execute only add-pnplistitem without batch I need pass number in english format with dot and not comma for decimal.

veronicageek commented 3 years ago

@paololec - Don't delete the template provided when opening an issue. Please fill the below so we can have a look at it. Also, if you get an error, run Get-PnPException just after and paste it in the "Actual Behavior" section.

Reporting an Issue or Missing Feature

Please confirm what it is that your reporting

Expected behavior

Please describe what output you expect to see from the PnP PowerShell Cmdlets

Actual behavior

Please describe what you see instead. Please provide samples of output or screenshots.

Steps to reproduce behavior

Please include complete script or code samples in-line

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

(you can retrieve this by executing Get-Module -Name "PnP.PowerShell" -ListAvailable)

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

paoIpao commented 3 years ago

Reporting an Issue or Missing Feature

Invoke-PnpBatch language problem. No exception but wrong number format (on site with default: italian). NumberCol is 100.945 and not 1.009,45 (seems that the expected input must be in locale language when using batch). If I execute only Add-PnPListItem WITHOUT BATCH NumberCol is correct 1.009,45 and the input $RowValues1 expected is english format (so also date in format MM/dd/yyyy and number in format 1009.45 ).

Other problem (only with batch) when using multiple value in multi choice (example: "Choice 1", "Choice 2") I have other error : (Message : Un nodo di tipo 'StartArray' è stato letto dal lettore JSON durante il tentativo di lettura di un valore di una proprietà, ma era previsto il nodo 'PrimitiveValue' o 'StartObject'. Stacktrace : at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in c:\PnPPowerShell\src\Commands\Base\PnPSharePointCmdlet.cs:line 70 at System.Management.Automation.CommandProcessor.ProcessRecord() ScriptLineNumber : 21 )

Expected behavior

NumberCol on sharepoint site is: 1.009,45

Actual behavior

NumberCol on sharepoint site (default language is italian) is: 100.945

Steps to reproduce behavior

$site = "https://tenant.sharepoint.com/sites/testSite" Connect-PnPOnline -Url $site

$list = Get-PnPList -Identity "TestList1" $batch = New-PnPBatch $RowValues1 = @{ "CurrencyCol" = "10.50"; "MultipleTextCol" = "Text text text text"; "CalculatedValueCol" = "11"; "PeopleCol" = "UserTest"; "YesNoCol" = "True"; "Title" = "Test1"; "DateCol" = "30/03/2021 00:00:00"; "NumberCol" = "1009.45"; "HyperlinkCol" = "https://www.microsoft.com"; "ChoiceCol" = "Choice 2"; "PeopleMultipleCol" = "user@mycompany.com"; "SingleLineTextCol" = "Test"; "MultipleChoiceCol" = "Choice 1"; "DateTime" = "31/03/2021 14:00:00"; } Add-PnPListItem -List $list -Values $RowValues1 -Batch $batch Invoke-PnPBatch $batch -StopOnException

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

1.6.0

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

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days

KoenZomers commented 2 years ago

Looking into this one.

KoenZomers commented 2 years ago

I can reproduce the behavior. Trying to think what would make most sense here to do. Please next time report one issue per issue report.

KoenZomers commented 2 years ago

Summarizing:

  1. Set regional setting for the site to Italian
  2. Add a number column to the list
  3. Add-PnPListItem -List "List" -Values @{Title="test";Num="1009,45"} => makes 100.945
  4. Add-PnPListItem -List "List" -Values @{Title="test";Num="1009,45"} -Batch $b => makes 1.009,45

So no batch: always US format, with batch: format of the site

Both cases send the values as provided to the SharePoint backend, so its the backend deviating here. We can't just fix it from the code side as doing so would not be backwards compatible. Probably have to go with documenting this behavior and leaving it as is.

KoenZomers commented 2 years ago

Updated documentation on second issue as well. When using a multiple choice column field, you must use this syntax:

-Values @{ChoiceColumnName="Choice 1;#Choice 2;#Choice 3"}

So separate multiple options using ;#

KoenZomers commented 2 years ago

Closing this issue as it should be resolved with the updated documentation in the above PR. Feel free to reopen if it doesn't work for you yet.