[BUG] #3840
Unanswered
AnselmaPerez
asked this question in
General
[BUG]
#3840
Replies: 1 comment
-
Does it work if you use Add-PnPListItem and input the data manually on the command? Maybe the DateTime is not correctly formatted? Just out of curiosity; your script uses $j as counter and $i when getting row's data. The script works well even with that? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Reporting an Issue
I am inserting list items to SharePoint online using batches of 100 items and I need to measure the time it takes to insert each batch, including adding the items to the batch. If the SharePoint Online list has a column of "Date and Time" data type, my batch is not being inserted and it does not throw an error either.
This code works:
for ($j = 0; $j -lt $rows.Count; $j++)
{
Add-PnPListItem -List $listTitle -Values @{
"EMPLOYEE_NUMBER"=$rows[$i].EMPLOYEE_NUMBER;
"EMPLOYEE_LAST_NAME"=$rows[$i].EMPLOYEE_LAST_NAME;
"EMPLOYEE_FIRST_NAME"=$rows[$i].EMPLOYEE_FIRST_NAME;
"EMPLOYEE_FULL_NAME"=$rows[$i].EMPLOYEE_FULL_NAME;
"EMPLOYEE_START_DATE"=$rows[$i].EMPLOYEE_START_DATE
} `
-Batch $itemBatch;
}
Invoke-PnPBatch -Batch $itemBatch;
But this code does NOT work if the list contains a "Date and Time" column. The items are not being inserted and the commands do not throw an error either.
However, if the list only has Text columns (and does not contain any Date and Time columns), the code below works too.
$timeTaken = Measure-Command -Expression {
for ($j = 0; $j -lt $rows.Count; $j++)
{
Add-PnPListItem -List $listTitle -Values @{
"EMPLOYEE_NUMBER"=$rows[$i].EMPLOYEE_NUMBER;
"EMPLOYEE_LAST_NAME"=$rows[$i].EMPLOYEE_LAST_NAME;
"EMPLOYEE_FIRST_NAME"=$rows[$i].EMPLOYEE_FIRST_NAME;
"EMPLOYEE_FULL_NAME"=$rows[$i].EMPLOYEE_FULL_NAME;
"EMPLOYEE_START_DATE"=$rows[$i].EMPLOYEE_START_DATE
} `
-Batch $itemBatch;
}
Invoke-PnPBatch -Batch $itemBatch;
}
Steps to reproduce behavior
Create a list in SharePoint Online with a couple of Text columns and one "Date and Time" column.
Try to insert items using batches using the code above.
So the problem occurs when using Measure-Command, batches and a Date and Time column at the same time.
There are 2 bugs:
What is the version of the Cmdlet module you are running?
Manifest 2.4.0 PnP.PowerShell Desk
Which operating system/environment are you running PnP PowerShell on?
Please let me know if you need additional information.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions