**Source URL:** https://general.veevavault.dev/vault-sdk/entry-points/triggers/role-triggers.md

# Role Triggers



A record role trigger executes custom business logic whenever roles are directly (manually) added or removed from an object record.

Users can manage manual role assignment  in the UI with object sharing settings or from a workflow using the add or remove role system step, through Vault API, or using the Vault Java SDK `RecordRoleService`. Each of these methods can activate an SDK record role trigger.

When these operations occur, the Vault Java SDK provides interfaces to interact with the record data, and the record role change before and after the record role change. Using the Java SDK, users can apply custom business logic in event handlers for `BEFORE` and `AFTER` Events.

<ThemeImage srcLight="/images/sdk/TiggerOrder.png" srcDark="/images/sdk/TiggerOrder.png" alt="Trigger Event Model"></ThemeImage>
This event-driven programming model allows developers to write small programs that target a specific object and Event to address common business requirements that standard application configurations cannot address.

## Example Use Cases {#example-use-cases}

The following examples illustrate typical uses for record role triggers by Event type:

### BEFORE {#before}

It is common practice to enforce validation rules on role assignment. The `BEFORE` Event allows the code to execute validation logic before the role assignments (or un-assignments) apply.

* Enforce cardinality constraints on role(s). For instance, ensure the assignment of only one user to the *Owner* role on an object record.

* Ensure that certain role assignments are mutually exclusive. For instance, the same user cannot be an *Owner* and an *Approver* on the record.

### AFTER {#after}

* Cascade role assignment from an object record to related object records. For example, when assigning a user in the *Editor* role on a *Campaign* object record, ensure the user has an *Editor* role on related Campaign-Product join records.

* Cascade role assignment from an object record to documents. For example, a *Campaign* object record may have related documents. When assigning a user to the *Viewer* role on the *Campaign*, ensure the user is a viewer on the related documents.

* Send an email notification after role assignment. For instance, the record owner receives an email notification if a user or a group is assigned as an *Approver* on the record.



---

**Previous:** [About Doctype Trigger Events](/vault-sdk/entry-points/triggers/doctype-triggers/about-doctype-trigger-events)  
**Next:** [Anatomy of a Record Role Trigger](/vault-sdk/entry-points/triggers/role-triggers/anatomy-role-triggers)