pnp / PnP-PowerShell

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

Add-PnPListItem creates empty item before setting fields #2118

Open expeepit opened 5 years ago

expeepit commented 5 years ago

Reporting an Issue or Missing Feature

I have a script which uses Add-PnPListItem, and at first glance it appears to work... a new list item is created with all the fields present and as expected.

However, we also use MS Flow which looks for newly created items in this list and initiates a workflow. This workflow is failing and upon further investigation the Version History tab of Sharepoint explains why... the first version of the new item is completely blank, and a 2nd version exists where all the fields have been set.

It seems that Add-PnPListItem creates a new and empty list item (which then triggers our MS Flow) and then the fields are SET in the new item.

Expected behavior

We need the newly created item to contain all the fields on the first touch, so that those details can be picked up correctly by MS Flow.

Actual behavior

A new / empty list item is created and then the fields updated / set.

Steps to reproduce behavior

cut down version of my script

$title = "test" $ticket = "1234"

$calendar = Get-PnPList "Change Control Management"

$newItem = Add-PnPListItem -List $calendar -ContentType "Item" -Values @{ Title = $title Ticket_x0020_Number = $ticket }

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

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

3.9.1905.3

How did you install the PnP-PowerShell Cmdlets?

ghost commented 5 years ago

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

fowl2 commented 4 years ago

This appears to be a duplicate of #859

Patrick959 commented 4 years ago

Any update on this? Or does anyone have an easy way to disable SPD workflows prior to running Add-PnPListItem?