Null vs. Undefined in Workflows
  • 12 Jul 2024
  • Dark
    Light
  • PDF

Null vs. Undefined in Workflows

  • Dark
    Light
  • PDF

Article summary

The difference between undefined and null is minimal, and they are often used interchangeably to represent non-value. As a result, users often need clarification and help, especially when designing workflows or debugging errors related to how (and where) these two values are used. This article will go through how each of these values act in a particular way with various tasks.

Null vs. Undefined Data Types

Within the framework of Itential Automation Platform, there are some scenarios where null and undefined behave differently than expected when they are used with various task types. To demonstrate this, please refer to the illustrative examples in the next section followed by a matrix that summarizes how each value behaves between IAP versions.

Merge Task Example

The workflow built in Figure 1 shows a newVariable task named test and an evaluation (eval) task to control the job execution path. In this case, it will pass through a success transition.

Figure 1
Workflow

In the sections that follow, we will use the example workflow to demonstrate how the merge task returns an object as specified by three distinct scenarios:

  • An undefined task input.
  • An undefined key in a task with multiple outputs (e.g., JST task).
  • An undefined job variable.

Essentially, the task type determines which key values are returned in the output. If a key value does not appear, the input used in the outgoing task will be null or undefined, depending on the release version you are using.

Undefined Task Input

Figure 2 shows a newVariable task input named fluke2 with its assigned value in Figure 3.

Figure 2
Merge Task Set 01

Figure 3

Merge Task Set 01

The task dialog for this merge task at the top of the workflow is shown in Figure 4. Notice how the merge task uses data from the newVariable.fluke2 job variable in key yo2.

Figure 4
Merge Task Set 01

After a successful workflow run, notice the key/values for the Incoming data to merge (Figure 5).

Figure 5
Merge Task Set 01

The merged object in the task output that returns shows a null value for the yo2 key (Figure 6).

Figure 6

Merge Task Set 01

Undefined Key in Task with Multiple Outputs (JST Task)

Using the same built workflow, this example shows a JST task input named george2 (Figure 7).

Figure 7

Merge Task Set 02

The schema settings for the george2 JST task are depicted in Figure 8.

Figure 8
Merge Task Set 02

In the workflow, the Incoming Schema named yo is assigned the value hello (Figure 9).

Figure 9

Merge Task Set 02

The merge task uses data from the george2 transformation task in key yo2 (Figure 10).

Figure 10

Merge Task Set 02

The incoming data_to_merge (object) that displays is shown in Figure 11.

Figure 11

Merge Task Set 02

Once the workflow run is complete, we see the following merged_object specific to the IAP release version.

Merged Object - IAP 2021.2 & 2022.1

The merged object in the task output for 2021.2 and 2022.1 shows a null value for the yo2 key, however it is stored as undefined (Figure 12).

Figure 12 (2021.2, 2022.1)

Merge Task Set 02

Merged Object - IAP 2023.1 & 2023.2

The merged object in the task output for 2023.1 and 2023.2 shows no value for the yo2 key (Figure 13).

Figure 13 (2023.1, 2023.2)

Merge Task Set 02

Undefined Job Variable

This example scenario is a newVariable task input named fluke (Figure 14). The assigned value is somethingfluke (Figure 15).

Figure 14

Merge Task Set 03

Figure 15

Merge Task Set 03

The merge task uses job task data from the fluke variable in key yo2 (Figure 16).

Figure 16

Merge Task Set 03

The incoming data_to_merge (object) that displays is shown in Figure 17.

Figure 17

Merge Task Set 03

Once the workflow run is complete, we see the following merged_object specific to the IAP release version.

Merged Object - IAP 2021.2 & 2022.1

The merged object in the task output for 2021.2 and 2022.1 shows a null value for the yo2 key, however it is stored as undefined (Figure 18).

Figure 18 (2021.2, 2022.1)

Merge Task Set 03

Merged Object - IAP 2023.1 & 2023.2

The merged object in the task output for 2023.1 and 2023.2 shows no value for the yo2 key (Figure 19).

Figure 19 (2023.1, 2023.2)

Merge Task Set 03

Task Matrix (Null vs. Undefined)

When trying to compare two values and one of them is null or undefined, it is obvious from the preceding example that you might get unexpected results. For task types other than merge, use the same workflow example (shown in Figure 1) but substitute each merge task with a different target task type and follow the same example exercise. The matrix (table) below outlines the expected result for each target task.

In the left-most (first) column, three undefined scenarios are listed. Each outgoing task is named in the top-most header row. Depending on the task type, if a key value does not appear, the input used for the outgoing task will be either null or undefined.

  • Step 1: Choose the undefined scenario listed in the first column and the outgoing task type from the top-most row.
  • Step 2: Move along the row of the undefined scenario and down the column of the task.
  • Step 3: The entry where the two meet is how it resolves the input for the task. For example, Transformation Task × Undefined Job Variable = undefined.

2023.2.0+ Merge Task Eval Task Transformation Task Child Job Task Workflow Engine (WFE) Automated Task Non-WFE Automated Task
Undefined Task Input null null null null null null
Undefined Key in Task with Multiple Outputs (JST Task) null null null null null null
Undefined Job Variable undefined undefined undefined undefined undefined null

2023.1.4 – 2023.2 Merge Task Eval Task Transformation Task Child Job Task Workflow Engine (WFE) Automated Task Non-WFE Automated Task
Undefined Task Input null null null null null null
Undefined Key in Task with Multiple Outputs (JST Task) undefined null null null null null
Undefined Job Variable undefined undefined undefined null undefined null

2023.1.0 – 2023.1.3 Merge Task Eval Task Transformation Task Child Job Task Workflow Engine (WFE) Automated Task Non-WFE Automated Task
Undefined Task Input null null null null null null
Undefined Key in Task with Multiple Outputs (JST Task) null null null null null null
Undefined Job Variable null undefined undefined null undefined null

2022.1 Merge Task Eval Task Transformation Task Child Job Task Workflow Engine (WFE) Automated Task Non-WFE Automated Task
Undefined Task Input null null null null null null
Undefined Key in Task with Multiple Outputs (JST Task) undefined null null null null null
Undefined Job Variable undefined undefined undefined undefined undefined null

2021.2 Merge Task Eval Task Transformation Task Child Job Task Workflow Engine (WFE) Automated Task Non-WFE Automated Task
Undefined Task Input null null null null null null
Undefined Key in Task with Multiple Outputs (JST Task) null null null null null null
Undefined Job Variable null undefined undefined null undefined null

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.