This sample script registers to the UpdateStates events for the entity types: File, Item and ChangeOrder.
The event is triggered when the lifecycle state of an entity is changed.
In our example we make use of the Restrictions event:
In the Restrictions event we check if the state is about to be changed to Released or in case of a ChangeOrder to Closed.
We also check if the user who is changing the state is the same who last modified the entity. If one of these rules is violated a restriction will be set.
In the default delivery the event script is disabled and located in the %PROGRAMDATA%\coolOrange\powerEvents\Events\Disabled folder.
The script can be tested by doing the following steps:
Enable the script by moving it to the directory %PROGRAMDATA%\coolOrange\powerEvents\Events.
Open the Vault Client.
Navigate to an Item, File or Change Order which can be released and was last modified by another Vault user.
Change the Lifecycle State to “Released” (or “Closed” for Change Orders).
A restriction dialog appears informing the user that the Lifecycle State of the entity can’t be released (or closed) as it was most recently edited by another user.