ScriptEval Examples

This document contains a few examples of ScriptEval configurations

Increment the value of userAccountControl with +2

The attribute userAccountControl will control how an AD account can be used. The numeric value of an active account can always be incremented by 2 in order to disable the account.

The property item.userAccountControl is fetched in the flow by an LDAPSearch, and will therefore be stored as a string value in an array.

{
    "name": "ScriptEval",
    "description": "Add +2 to userAccountControl",
    "config": {
        "source": "items.forEach((id, item) => { const val = item.userAccountControl[0]; const increment = 2; if (val !== '' && !isNaN(val)) { item.userAccountControl[0] = String(Number(val) + increment); }});"
    }
}

Create an item form a json-structure

Some json-data is present in the state.

The item property customer is created in the flow from a previous request

{
  "name": "ItemPropertyAdd",
  "config": {
    "values": {
      "customer": "@json:${state.body.ocs.data.users.all}"
    }
  }
}

The script will create a new item from the content of the customer property.

Generate sAMAccountName by substring of givenName and sn

The item property sAMAccountName will be added to all items. The property will be created by the first 3 characters from givenName and the first 3 characters from sn.

Count number of days since lastLogonTimeStamp

The item property days will be added to all items. The property will contain the date diff between L (containing the value of lastLogonTimeStamp) and current time.

Last updated