Moogsoft Docs

createWorkflow

A MoogDb v2 method that creates a new workflow at the end of a Workflow Engine Moolet sequence. To move it, use reorderWorkflows.

Back to MoogDb V2 API Method Reference.

Request arguments

Method createWorkflow takes the following request arguments:

Name

Type

Required

Description

moolet_name

String

Yes

Name of the Workflow Engine Moolet that the new workflow belongs to.

workflow_name

String

Yes

Name of the new workflow. Must be unique.

description

String

No

Description of the new workflow.

entry_filter

Filter in JSON or SQL format

No

Filter to determine which events, alerts or Situations can enter the workflow. You can use an SQL-like query. See Create an advanced filter for more information on creating SQL-like filters. Leave empty for the workflow to accept all events, alerts or Situations.

sweep_up_filter

Filter in JSON or SQL format

No

Filter to intake any additional events, alerts or Situations from the database. You can use an SQL-like query. See Create an advanced filter for more information on creating SQL-like filters.

first_match_only

Boolean

Yes

If enabled, events, alerts, and Situations only pass through actions on the first time they enter this workflow.

operations

JSON Array

Yes

List of properties relating to each operation:

Name

Type

Required

Description

type

String

Yes

Type of operation. Options are: 'action', 'decision' and 'delay'.

operation_name

String

Yes, for 'action' and 'decision' types.

Name of the operation.

function_name

String

Yes, for 'action' and 'decision' types.

Name of the function.

forwarding_behavior

String

No

function_args

JSON Object

No

Arguments for the function.

duration

Integer

Yes, for 'delay' type.

Length of time before the message goes to the next operation.

reset

Boolean

Yes, for 'delay' type.

Determines whether the timer resets after each occurrence. Not available if you have set a workflow to first_match_only.

The timer is reset only if an occurrence with the same ID is received (alert_id or situation_id) within the current 'delay' timeframe.

Examples

The following examples demonstrate typical use of method createWorkflow:

Request example

Example request to create a new workflow "ChangeInfoWorkflow":

var id = moogdb.createWorkflow(
{
    "moolet_name": "Alerts Workflows",
    "workflow_name": "ChangeInfoWorkflow",
    "description": "Changingthealertinformation",
    "entry_filter": {
            "column": "severity",
            "op": 5,
            "value": 3,
            "type": "LEAF"
    },
    "sweep_up_filter": {
            "column": "description",
            "op": 4,
            "value": "description",
            "type": "LEAF"
    },
    "first_match_only": false,
    "operations": [{
                    "type": "action",
                    "function_name": "functionA",
                    "function_args": {
                            "admin": 2
                    },
                    "operation_name": "do something"
            },
            {
                    "type": "delay",
                    "delay": 30,
            "reset": false
            }
    ]
});