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.
{
"name": "ScriptEval",
"config": {
"source": "items.item('abc123').customer.forEach((value) => {var item= items.create(value); item.customer=value;});"
}
}
Last updated