Set-KFItemData

Syntax

Set-KFItemData
  [[-Key] <string>]
  [-Data] <object>
  [-Item <list-item-object>]
  [-ThrowErrors[:$true]]

Support

>= kenaflow 1.0.0

Return

Nothing.

Description

This is only available in SharePoint list or state machine workflows!

The cmdlet can be used to store data in the context of the list item that can be reloaded later.

The data is serialized using the specified -Key and the unique ID of the currently processed list item in the workflow data list.

Serialization means that the objects are brought into a storable format, here PowerShell CLIXML and JSON.

To store several different objects in the context of the list element, the additional -Key can be specified.

Serialization does not allow the entire state of a complex object to be transferred in CliXML or JSON, but ultimately only the data of the object. This must be taken into account. For example, a SharePoint list element cannot be serialized as an object (ListItem object) so that it could be reloaded and modified later. This limitation is a typical problem in software development and not limited to kenaflow.

In the workflow data list, a persistence key is formed from the workflow ID, the list element ID and, if specified, the -Key. This links the data to the workflow and to the list element.

To get the data, use the Get-KFItemData cmdlet.

Parameters

[-Key] <string>

The key that is used to read the serialized data.

[-Data] <object>

The data that is to be persisted.

[-Item <list-item-object>]

The SharePoint list item in whose context the data is serialized.

[-ThrowErrors[:$true]]

This is a default parameter for all kenaflow cmdlets. If set to $true (default!) the engine will pass exception within the cmdlet to the script for further handling.

Example

$item = Get-PnPListItem -List "Custom List" -Id 1
Set-KFItemData -Item $item -Key "kenaflow" -Data @{"is" = "a workflow engine for SharePoint, Email and PowerShell"}
Write-KFLog (Get-KFItemData -Item $item -Key "kenaflow")
Remove-KFItemData -Item $item -Key "kenaflow"