# Administration (scripting) # Introduction to Custom scripts ## What is a Custom script? The Administration Addon provides the capacity to launch custom scripts to perform any functionality or process that the Soffid API has available. Additionally, with this addon, there is available the possibility to enable a special to get the metrics of the performance of the Soffid IAM components. Through the Custom scripts page you could perform the next operations: - You could create a new custom script. - You could execute the custom script **On demand** by clicking on the Execute now button. - You could execute the custom script as a **Scheduled** task, and it will be executed as you have configured the timetable. *(\*1)* - **Month**: number of the month (1-12) when the task will be performed. - **Day**: number of the day (1-31) when the task will be performed. - **Hour**: hour (0-23) when the task will be performed. - **Minute**: minute (0-59) when the task will be performed. - **Day of week**: number of day (0-7 where 0 means Sunday) of the week when the task will be performed. - **Server**: where the agent is running. - You could define the event in which the script will be launched: - [**On user change**](#bkmrk-on-user-change): this kind of script will be launched when any user changes. - [**On revoke** **permission**](#bkmrk-on-grant-permission): this type of script will be launched when permissions are revoked. - [**On grant permission**](#bkmrk-on-grant-permission): this type of script will be launched when permissions are assigned. #### On user change When you define an event on user change, the user object will be available on the **user variable** to access and operate with it.

To find more details about the user object, you can visit the [Soffid Objects page](https://bookstack.soffid.com/books/soffid-3-reference-guide/page/soffid-objects#bkmrk-user-object).

#### On grant permission When you define an event on revoke or grant permission, the grant object will be available on the **grant variable** to access and operate with it.

To find more details about the grant object, you can visit the [Soffid Objects page](https://bookstack.soffid.com/books/soffid-3-reference-guide/page/soffid-objects#bkmrk-grant-object).

## Documentation Below you could find a list of helpful links related to the building of custom scripts

API for the internal classes of Soffid: [https://download.soffid.com/doc/console/latest/uml/](https://download.soffid.com/doc/console/latest/uml/)

Custom utility classes: [https://bookstack.soffid.com/books/soffid-3-reference-guide/page/utility-classes](https://bookstack.soffid.com/books/soffid-3-reference-guide/page/utility-classes)

--- *(\*1) For each value of mont, day, hour, minute or day of the week:* *- \* means any month, day, hour, minute, or day of week. e.g. \*/5 to schedule every five minutes. \- A single number specifies that unit value: 3 \- Some comma separated numbers: 1,3,5,7 \- A range of values: 1-5* # How to install Custom scripts in Soffid ## Installation ### Download Please download the Soffid Administration (scripting) add-on. You can download it at the following link [http://www.soffid.com/download/enterprise/](http://www.soffid.com/download/enterprise/) if you have Soffid user with authorization, or in the following [http://download.soffid.com/download/](http://download.soffid.com/download/) by registering. ### Upload 1. Once the Federation add-on is downloaded, please log in to IAM Console.

You need to be an administrator user of the Soffid console or a user with permissions to upload addons.

It is recommended to upload the addons to master, this is the way to maintain updated all, master and tenants if there are.

2. In the Soffid console, please go to: `Main Menu > Administration > Configure Soffid > Global Settings > Plugins` 3. Then, click the add button (+) and pick the file and Soffild will upload the addon file.

For more information visit the [Addons Getting started](https://bookstack.soffid.com/books/addons-getting-started/page/getting-started "Addons installation") page.

4. Finally, when the addon is installed, it will be required to restart the Soffid Console. 5. Once the Soffid console is restarted, you could check the plugin was uploaded properly on the plugins page: `Main Menu > Administration > Configure Soffid > Global Settings > Plugins` 6. Now, you can use the Custom scripts. # Custom scripts samples Custom scripts samples # Sample scripts {{@100}} # Event Sample scripts #### On grant permission: Update a user attribute when assigning a specific permission ```shell if (grant.roleName.equals("RS002")) { user = serviceLocator.getUserService().findUserByUserName(grant.user); if (user != null) { attributes = serviceLocator.getUserService().findUserAttributes(user.userName); if (attributes == null) { attributes = new HashMap(); } attributes.put("language", "Spanish"); serviceLocator.getUserService().updateUserAttributes(user.userName, attributes); } } ```