Register EngineEvent - PowerShell
Overview
The Register-EngineEvent
command registers an event for the workflow engine. This allows the workflow to receive notifications when the event occurs, such as when a new item is created in a specified list or when a file is modified in a specified folder.
Syntax
Register-EngineEvent -Source [<Source>] -Type [<Type>] -Name [<Name>] -Data [<Data>] -RunNow -SkipDuplicates
Options/Flags
| Option | Description | Default |
|—|—|—|
| -Source
| Specifies the source of the event. This can be a SharePoint list, library, folder, or file. | Required |
| -Type
| Specifies the type of event. This can be ItemAdded
, ItemUpdated
, ItemDeleted
, or ItemMoved
. | Required |
| -Name
| Specifies the name of the event. This is used to identify the event when it is received by the workflow. | Required |
| -Data
| Specifies the data that is associated with the event. This can be any type of data, such as a string, number, or object. | Optional |
| -RunNow
| Specifies whether the workflow should be run immediately after the event is registered. | $false
|
| -SkipDuplicates
| Specifies whether the workflow should skip duplicate events. | $true
|
Examples
The following command registers an event for a SharePoint list named “Tasks”. The event is triggered when a new item is added to the list.
Register-EngineEvent -Source "Lists/Tasks" -Type "ItemAdded" -Name "NewTask"
The following command registers an event for a folder named “Documents”. The event is triggered when a file is modified in the folder.
Register-EngineEvent -Source "Documents" -Type "ItemUpdated" -Name "FileUpdated"
Common Issues
One common issue that can occur when using the Register-EngineEvent
command is that the event is not triggered when it should be. This can be caused by a number of factors, such as:
- The event source is not correctly configured.
- The event type is not supported.
- The event name is already in use.
- The workflow is not running.
Integration
The Register-EngineEvent
command can be used with other PowerShell commands to create powerful workflows. For example, you can use the Register-EngineEvent
command to register an event for a SharePoint list, and then use the Start-Workflow
command to start a workflow that is triggered by that event.
Related Commands
Get-EngineEvent
Unregister-EngineEvent
Start-Workflow