---
title: Update script
description: Connectors continue to be released outside the IDM release. For the latest documentation, refer to the OpenICF documentation.
component: pingidm
version: 7.2
page_id: pingidm:connector-dev-guide:scripts/script-update
canonical_url: https://docs.pingidentity.com/pingidm/7.2/connector-dev-guide/scripts/script-update.html
---

# Update script

|   |                                                                                                                                                                                   |
| - | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|   | Connectors continue to be released outside the IDM release. For the latest documentation, refer to the [OpenICF documentation](https://docs.pingidentity.com/openicf/index.html). |

An update script updates an object in the external resource. Connectors that do not support update operations should throw an `UnsupportedOperationException`.

A sample update script for an SQL database is provided in `openidm/samples/scripted-sql-with-mysql/tools/UpdateScript.groovy`.

* Input variables

  The following variables are available to an update script:

  * configuration

    A handler to the connector's configuration object.

  * options

    A handler to the Operation Options.

  * operation

    An OperationType that corresponds to the action (`UPDATE`).

  * objectClass

    The object class that is updated, such as `__ACCOUNT__` or `__GROUP__`.

  * attributes

    A collection of `ConnectorAttributes` that represent the entry attributes to update.

  * uid

    The UID of the object to be updated. The UID corresponds to the OpenICF `UID` attribute.

  * id

    The name of the object to be updated (optional). The id corresponds to the OpenICF `__NAME__` attribute. It will not be injected and set unless the update is a rename.

  * log

    A logger instance for the connector.

* Returns

  The user unique ID (OpenICF `__UID__`) of the updated object. The `type` of the returned UID must be a `string` or a `Uid`. If the UID is not modified by the update operation, return the value of the uid injected into the script.

Update Script

```groovy
def operation = operation as OperationType
def updateAttributes = attributes as Set<Attribute>
def configuration = configuration as ScriptedConfiguration
def id = id as String
def log = log as Log
def objectClass = objectClass as ObjectClass
def options = options as OperationOptions
def uid = uid as Uid

log.ok("Update...")
switch (operation) {
    case OperationType.UPDATE:
        switch (objectClass) {
            case ObjectClass.ACCOUNT:
// ...
                    for (Attribute a : updateAttributes) {
                        if (a.is(Name.NAME)) {
// ...
return uid
```
