Set-KFObject

Syntax

Set-KFObject
  -Name <string>
  -Object <object-as-PSObject>
  [-ThrowErrors[:$true]]

Support

>= kenaflow 4.0.11

Return

Description

This cmdlet can be used to store data in an in-memory-cache during the current workflow execution. After the workflow processing is finished the in-memory-cache is cleared. The workflow script has no access to the in-memory-cache of other workflows.

If this cmdlet is used in a workflow script that is executed from an remote event the in-memory-cache is cleared after the current event processing.

Parameters

[-Name] <string>

The key that is used to write data

[-Object] <object-as-PSObject>

This is the data to be stored in memory.

[-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

The proProcessingScript specified in _wfconfig.ps1 could include the following line of Powershell script code:

Set-KFObject -Name "ListOfDataForExcelExport" -Object @()

The SharePoint workflow script could include this script code:

$d = Get-KFObject -Name "ListOfDataForExcelExport"
$d += @{Title = $item["Title"]; Id = $item.Id; Author = $item["Author"].LookupValue; Editor = $item["Editor"].LookupValue}
Set-KFObject -Name "ListOfDataForExcelExport" -Object $d

This creates an empty list in memory.

The postProcessingScript specified in _wfconfig.ps1 could include the following line of Powershell script code:

$data = Get-KFObject -Name "ListOfDataForExcelExport"
New-KFExcelFile -Input $data -SheetName "Output" -AsBase64 -Fields @("Id", "Title", "Author", "Editor")

Remove-KFObject -Name "ListOfDataForExcelExport" # This is not required because at the end of a workflow processing the in-memory-object is cleared!

Discussion