Dynamic evaluation

Capabilities

Capability

Support

Comment

Extract a single element

Supported feature

See Extracting from single item

Extract a list of elements

Supported feature

See Extraction of a list of items

Use schema with dynamic elements

Supported feature

See Extraction of a map of key values given the schema

Use complex JSON path query for dynamic evaluation

Supported feature

See Extraction of a map of key values given the schema

Context

Web evaluation involves using user input alongside integrator logic. It serves various purposes across multiple components :

  • Menus and toolbars

  • Schematics

  • On-clicks handler on widgets

  • …

To evaluate expressions, the web performs these steps:

  1. Find all dynamic expression placeholder (between ${ and }).

  2. Replace all ${<dynamic content replacement>} available during evaluation. Missing items are replaced by empty strings. JSON structure can be access through . separator (ie. ${user.username}).

  3. Evaluate and retrieve its content for further usage. Should an error occurs, resulting evaluation returns an undefined result.

Evaluation language is JavaScript and supports syntactic sugar such as object?.hypotheticalAccessor.

Building dynamic data is done through pipeline evaluation with the following steps:

  1. Extraction with extract keyword. This allows context value extraction using JSONPath query. Resulting extraction will always be an array of elements. Context parts can be extracted and sent with the extract keyword.

  2. Evaluation with expression keyword. This allows JavaScript code evaluation. Returns the evaluation result.

  3. Transformation with as keyword into the desired type.

Extracting from single item

In the following example, the your-variable field is filled with extracting content from context.field.dynamic. Since extraction result is an array, we transform it with as transformer. The static field will be filled with this is static content.

{
    "input": {
        "your-variable": {
            "extract": "context.field.dynamic",
            "as": "string"
        },
        "static": "this is static content"
    }
}

Extraction of a list of items

{
    "tags": {
        "extract": "rows.clicked.tags[*]",
        "as": "string"
    }
}

Extraction of a map of key values given the schema

Given the schema :

{
    "additionalData": {
        "type": "array",
        "items": {
            "type": "object",
            "properties": {
                "key": {
                    "type": "string"
                },
                "value": {
                    "type": "string"
                }
            }
        }
    }
}

Use the condition :

{
  "additionalData": {
      "extract": "rows.clicked.additionalData[*]",
      "expression": "${extraction}.reduce((accumulator, currentObject) => { return { ...accumulator, [currentObject?.key]:currentObject?.value }; }, {});"
  }
}