Skip to main content

removeEmptyPayloadValues

A Workflow Engine function that removes empty values from a JSON object. It is specifically designed to remove empty values from payloads (in the workflowContext) created by the getPayload, or getPayloadFromInform functions.

The removeEmptyPayloadValues function removes empty values from all payloads (as when a sweep up filter was used), and only needs to be run once for all currently held payloads to be "cleaned."

Back to Workflow Engine Functions Reference.

Arguments

Workflow Engine function removeEmptyPayloadValues takes the following arguments:

Name

Required

Type

Description

strict

no

string (true | false)

Use "strict" mode, removing all "falsey" values. Default is "false" (0, and false are allowed values).

Example

The function of the action is unchanged, but the source and destination are the payloads held in the workflowContext.

Given a workflow that has the following function, and a sweep up filter:

  • getPayload

  • removeEmptyPayloadKeys

The workflowContext may look like this after the getPayload function, a payload per in scope alert (1 trigger and 2 swept up alerts):

{
    "payloads": {
        "35415": {
            "a": "a",
            "b": "",
            "c": [],
            "d": {
                "full_object": {
                    "key1": "value1"
                },
                "empty_object": {},
                "empty": ""
            },
            "e": 0,
            "f": false,
            "g": true,
            "h": 35415,
            "i": null
        },
        "35413": {
            "a": "a",
            "b": "",
            "c": [],
            "d": {
                "full_object": {
                    "key1": "value1"
                },
                "empty_object": {},
                "empty": ""
            },
            "e": 0,
            "f": false,
            "g": true,
            "h": 35413,
            "i": null
        },
        "35414": {
            "a": "a",
            "b": "",
            "c": [],
            "d": {
                "full_object": {
                    "key1": "value1"
                },
                "empty_object": {},
                "empty": ""
            },
            "e": 0,
            "f": false,
            "g": true,
            "h": 35414,
            "i": null
        }
    }
}

After the removeEmptyPayloadValues function runs (with “strict” set to true) the payloads in the workflowContext would look like the following:

{
    "payloads": {
        "35415": {
            "a": "a",
            "d": {
                "full_object": {
                    "key1": "value1"
                }
            },
            "g": true,
            "h": 35415
        },
        "35413": {
            "a": "a",
            "d": {
                "full_object": {
                    "key1": "value1"
                }
            },
            "g": true,
            "h": 35413
        },
        "35414": {
            "a": "a",
            "d": {
                "full_object": {
                    "key1": "value1"
                }
            },
            "g": true,
            "h": 35414
        }
    }
}