# Sample.ValidateProperties

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.

## Testing

The script can be tested by doing the following steps:

1. Open the Vault Client

2. Navigate to an Item, File or Change Order which can be released and was last modified by another Vault user.

3. Change the Lifecycle State to “Released” (or “Closed” for Change Orders).

4. 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.

In the default delivery the event registration for this script is disabled, therefore you will have to enable it by uncommenting following lines:

#Register-VaultEvent -EventName UpdateFileStates_Restrictions ...
#Register-VaultEvent -EventName UpdateItemStates_Restrictions ...
#Register-VaultEvent -EventName UpdateChangeOrderState_Restrictions ...