Set-KFState

Syntax

Set-KFState
  [-State] <next-state-key>
  [-ThrowErrors[:$true]]

Support

>= kenaflow 1.0.0

Return

Nothing.

Description

This cmdlet does only work in SharePoint state machine workflows!

It is used to change the workflow state of the currently processed list item.

-State <next-state-key> specifies the next state.

The states are configured in _wfconfig.ps1, e.g.:

#...

	States = @{
		"(empty)" = @{
			ExecutionOrder = -1; 
			Enabled = $false
		};
		"1.0" = @{
			Title = "State 1.0";  
		};
		"2.0" = @{
			Type="query";
			Query="{{Title}} == string 'Test' & {{Modified}} > datetime [[TODAY]] & {{Editor}} != lookupid [[USERID]]"			
		};
		"3.0" = @{
			Title = "Last State";
			Script = "S_laststate.ps1"; 
		};
		"4.0" = @{
			Enabled = $false;
			Title = "Ignore";
		};
	}
	
# ...

You can use then Set-KFState "4.0" to change the list items workflow state to "4.0".

You should not do further actions in the workflow after you executed this cmdlet.


# some lines of workflow script code

if ($x -eq $true) {
	Set-KFState "1.0"
	Stop-KFScript
} 

# some more lines of workflow script code.

Set-KFState "2.0"

# End of File

Parameters

[-State] <next-state-key>

Specifies the next workflow state.

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

See section "Description" above.