PingOne Advanced Identity Cloud

Call a script from the IDM configuration

To call a script from the IDM configuration, edit the configuration object. For example:

Provide a script source
{
    "type" : "text/javascript",
    "source": "scriptSource"
}

Script variables are not necessarily simple key:value pairs, and can be any arbitrarily complex JSON object.

type

string, required

The script type.

IDM supports "text/javascript".

source

string, required

Specifies the source code of the script to be executed.

Use namespace variables passed into scripts with the globals map. Passing variables in this way prevents collisions with the top-level reserved words for script maps, such as source and type. This example uses the globals map to namespace the variables passed in the previous example.

"script": {
    "type" : "text/javascript",
    "source" : "scriptSource",
    "globals" : {
        "fromSender" : "admin@example.com",
        "toEmail" : "user@example.com"
    }
}

Examples

The following example script (in the mapping configuration) determines whether to include or ignore a target object in the reconciliation process based on an employeeType of true:

"validTarget" : {
    "type" : "text/javascript",
    "source" : "target.employeeType == 'external'"
}

The following example script (in the mapping configuration) sets the __PASSWORD__ attribute to defaultpwd when IDM creates a target object:

"onCreate" : {
    "type" : "text/javascript",
    "source" : "target.__PASSWORD__ = 'defaultpwd'"
}

You can pass variables to your scripts to provide contextual details at runtime by declaring the variable name in the script reference.

The following scheduled task configuration calls a script that triggers an email notification, but sets the sender and recipient of the email in the schedule configuration, rather than in the script itself:

{
    "enabled" : true,
    "type" : "cron",
    "schedule" : "0 0/1 * * * ?",
    "persisted" : true,
    "invokeService" : "script",
    "invokeContext" : {
        "script" : {
            "type" : "text/javascript",
            "source" : "scriptSource",
            "fromSender" : "admin@example.com",
            "toEmail" : "user@example.com"
        }
    }
}