Sample event scripts
powerEvents installs some sample event scripts to display some of the capabilities of the product in common scenarios.
One of the samples, Sample.ValidateProperties is intended to show how custom code can be executed on Vault lifecycle state transitions.
The sample event scripts are customizable and can be used as a template to easily create custom scripts to fit specific customer requirements.
To get started open any Powershell IDE or use the “powerEvents 23.0 ISE” shortcut in the start menu, which automatically opens the event script Sample.ValidateProperties.ps1.
Open event script as Administrator
On some systems the directory “C:\ProgramData\” is write protected so the powershell IDE needs to be run as an Administrator, by right clicking Windows PowerShell ISE in the start menu and clicking “Run as administrator”.
Afterwards the sample script can be opened by going to “File” -> “Open…” and open the file “C:\ProgramData\coolOrange\powerEvents\Events\Sample.ValidateProperties.ps1”.
Activating a sample script
Sample event scripts are disabled by default, in order to enable an event script, uncomment the
In this example lines 10 to 12 need to be changed from:
9 10 11 12
# To enable/disable the restriction of Lifecycle state changes to Files, Items and Change Orders which have been modified by different Vault users, comment/un-comment the following lines. #Register-VaultEvent -EventName UpdateFileStates_Restrictions -Action $validateProperties #Register-VaultEvent -EventName UpdateItemStates_Restrictions -Action $validateProperties #Register-VaultEvent -EventName UpdateChangeOrderState_Restrictions -Action $validatePropertiesForChangeOrder
9 10 11 12
# To enable/disable the restriction of Lifecycle state changes to Files, Items and Change Orders which have been modified by different Vault users, comment/un-comment the following lines. Register-VaultEvent -EventName UpdateFileStates_Restrictions -Action $validateProperties Register-VaultEvent -EventName UpdateItemStates_Restrictions -Action $validateProperties Register-VaultEvent -EventName UpdateChangeOrderState_Restrictions -Action $validatePropertiesForChangeOrder
After uncommenting the Register-VaultEvent calls the changes need to be saved by clicking “File” -> “Save”.
Testing the script
The goal of the Sample.ValidateProperties script is to prevent a user from releasing a file that has recently been changed by an other user.
Testing this sample event script requires two different Vault accounts.
Start the Vault Client and log in with the first account (in this example “Administrator” is used).
Navigate to a file and change the lifecycle state to a non-release state.
In this example the state of Intake Casing.ipt is changed to “For Review”:
Changing Vault account
Log out by going to “File” -> “Log Out” and log in again with the second Vault account.
Navigate back to previously changed file and try to change its lifecycle state to a released state. In this example the state of Intake Casing.ipt is changed to “Released”:
The lifecycle transition for Intake Casing.ipt to the “Released” state is blocked by a powerEvents restriction
because the latest modification was performed by a different Vault account (“Administrator” in this example) and the second Vault account is now trying to release the file: