Forum Discussion
pisani675
Jul 15, 2024Copper Contributor
Add-PnPListItem not insert record if date field is null
Hi,
I am trying to add some reocord to a sharepoint list.
My source is SQL server and I have some record with a date filled and some others with a date null value.
My code is this:
Add-PnPListItem -List $ListName -Values @{
"Title" = $result.GetValue(0)
"Customer"=$result.GetValue(1)
"Address" = $result.GetValue(2)
"Description" = if($result.GetValue(4)){$result.GetValue(4)} Else {''}
"StopDate" = if($result.GetValue(3)){$result.GetValue(3)} Else {$null}
} -ErrorAction SilentlyContinue #
I did some tests:
1) without testing the null value of the date, the record is not inserted
2) by testing the value first I tried entering
Else {$null}
Else {''}
Else {''}
Else {}
and in all cases the record is not inserted.
Where am I going wrong?
Thank you
No RepliesBe the first to reply