---
title: Variables available to role assignment scripts
description: The optional onAssignment and onUnassignment event scripts specify what should happen to attributes that are affected by role assignments when those assignments are applied to a user, or removed from a user.
component: pingidm
version: 8.1
page_id: pingidm:scripting-guide:assignment-script-variables
canonical_url: https://docs.pingidentity.com/pingidm/8.1/scripting-guide/assignment-script-variables.html
keywords: ["Scripting", "Variables", "Roles", "Assignments"]
---

# Variables available to role assignment scripts

The optional `onAssignment` and `onUnassignment` event scripts specify what should happen to attributes that are affected by [role assignments](../objects-guide/roles.html#creating-an-assignment) when those assignments are applied to a user, or removed from a user.

These scripts have access to the following variables:

* `sourceObject`

* `targetObject`

* `existingTargetObject`

* `linkQualifier`

The standard assignment scripts, `replaceTarget.js`, `mergeWithTarget.js`, `removeFromTarget.js`, and `noOp.js` have access to all the variables in the previous list, as well as the following:

* `attributeName`

* `attributeValue`

* `attributesInfo`

|   |                                                                                                                                                             |
| - | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|   | Role assignment scripts must always return `targetObject`, otherwise other scripts and code that occur downstream of your script will not work as expected. |
