Pre-Defined Variables

Starting with kenaflow 4.0.22 the engine injects several pre-defined variables into the PowerShell script during execution.

The content of the variables depends on the current workflow, execution state, etc.

Depending on the script context there are different variables available.

All pre-defined variables start with prefix KF.

Workflow Configurtation Parsing

The workflow configuration file _wfconfig.ps1 is a PowerShell script that returns a single Hashtable object containing the workflow configuration. This file is parsed using PowerShell. Therefore the code of _wfconfig.ps1 gets executed.

The following variables are injected:

  • $KFInstanceName
  • $KFInstanceVersion
  • $KFInstanceId
  • $KFWorkflowConfigFileInfo => Object of type System.IO.FileInfo

PreWorkflowExecution Script Block

When debugging a workflow script the cmdlet Invoke-Kenaflow is used to initialize the runtime environment.

The cmdlet accepts a script block with parameter -PreWorkflowExecurion. This script block is executed before the workflow script is executed.

Inside the scriptblock the following variables are injected:

  • $KFInstanceName
  • $KFInstanceVersion
  • $KFInstanceId
  • $KFWorkflow
  • $KFConfig
  • $KFLastRun
  • $KFCurrentStart
  • $KFLastRunDT
  • $KFCurrentStartDT
  • $KFLastRunUtc
  • $KFCurrentStartUtc
  • $KFLastRunUtcDT
  • $KFCurrentStartUtcDT

For different workflow types there are additional variables available.

Additional Variables in EMail-IMAP Workflows

  • $KFIMAPServerObj

Additional Variables in EMail-POP3 Workflows

  • $KFPOP3ServerObj

Additional Variables in EMail-Exchange Workflows

  • $KFExchangeWSServerObj

Additional Variables in SharePoint Enabled EMail Workflows

  • $KFCurrentWeb
  • $KFContext
  • $KFSharePointContext

Additional in Storage Workflows

  • $KFEventData

Additional Variables in in (all) SharePoint Workflows

  • $KFCurrentWeb
  • $KFContext
  • $KFSharePointContext
  • $KFEventData

Additional in SharePoint State Machine Workflows

  • $KFWorkflowStates => An object of type Dictionary<string,int> that contains state names and ids.

Additional Variables in PowerShell Workflows and Custom Workflows

currently none

ErrorHandling-Script

In a workflow an "Error Handling Script" can be specified in _wfconfig.ps1.

The scripts is called with some information about the error (Exception) and the following pre-defined variables:

  • $KFException
  • $KFInstanceName
  • $KFInstanceVersion
  • $KFInstanceId
  • $KFWorkflow
  • $KFConfig

The following variables are optionally injected, depending on the context.

  • $KFCurrentItem
  • $KFEventData
  • $KFCurrentWeb
  • $KFCurrentList

PreProcessing Script and PostProcessing Script

Every workflow can have a "PreProcessing" script and/or a "PostProcessing" script.

The following variables are injected during runtime:

  • $KFInstanceName
  • $KFInstanceVersion
  • $KFInstanceId
  • $KFWorkflow
  • $KFEventData

(All) SharePoint Workflows

  • $KFInstanceName
  • $KFInstanceVersion
  • $KFInstanceId
  • $KFWorkflow
  • $KFContext
  • $KFSharePointContext
  • $KFCurrentWeb
  • $KFEventData
  • $KFConfig
  • $KFLastRun
  • $KFCurrentStart
  • $KFLastRunDT
  • $KFCurrentStartDT
  • $KFLastRunUtc
  • $KFCurrentStartUtc
  • $KFLastRunUtcDT
  • $KFCurrentStartUtcDT
  • $KFInVersionConflict

Additional in SharePoint List Workflows and State Machine Workflows

  • $KFItem
  • $KFCurrentList
  • $KFLastEditor
  • $KFLastModified
  • $KFLastItemModifiedFlag
  • $KFLastExecutionType

Additional Variables in SharePoint State Machine Workflows

  • $KFCurrentWorkflowState
  • $KFWorkflowStates

Pre Query Script of SharePoint List and State Machine Workflows

SharePoint List workflows and SharePoint State Machine workflows can have a script "PreQuery" that is spcified in _wfconfig.ps1 and is executed just before the CAML query is send to SharePoint to retrieve the items.

The following variables are injected into the Pre Query Script:

  • $KFInstanceName
  • $KFInstanceVersion
  • $KFInstanceId
  • $KFWorkflow
  • $KFContext
  • $KFSharePointContext
  • $KFCurrentWeb
  • $KFCurrentList
  • $KFEventData
  • $KFConfig
  • $KFLastRun
  • $KFCurrentStart
  • $KFLastRunDT
  • $KFCurrentStartDT
  • $KFLastRunUtc
  • $KFCurrentStartUtc
  • $KFLastRunUtcDT
  • $KFCurrentStartUtcDT
  • $KFInVersionConflict

Custom Workflow

Custom workflows can be defined using kenaflow Plugins.

The following variables are injected into the script execution:

  • $KFPlugin => A reference to the kenaflow Plugin used for this workflow
  • $KFConnection => Depending on the kenaflow Plugin
  • $KFEventData

EMail Workflow

The following variables are available during execution:

  • $KFInstanceName
  • $KFInstanceVersion
  • $KFInstanceId
  • $KFItem
  • $KFWorkflow
  • $KFConfig
  • $KFLastRun
  • $KFCurrentStart
  • $KFLastRunDT
  • $KFCurrentStartDT
  • $KFLastRunUtc
  • $KFCurrentStartUtc
  • $KFLastRunUtcDT
  • $KFCurrentStartUtcDT
  • $KFInVersionConflict

Additional Variables in SharePoint Enabled EMail Workflows

  • $KFContext
  • $KFSharePointContext
  • $KFCurrentWeb
  • $KFInVersionConflict