Skip to main content

Default Values

Default Blank Valuesโ€‹

You can use Gizmo to apply a default value if it is blank

In this example the expression is trying to select the "Department" and "Area" properties of a node with the option to provide default values if these properties are missing.

node.pick("Department", "Area")
.defaultsWith({ Department: "Unknown Department", Area: "Unknown Area" })

Explanation of the script:

node.pick("Department", "Area"): This line selects the "Department" and "Area" properties from the node.

.defaultsWith({ Department: "Unknown Department", Area: "Unknown Area" }): If the "Department" or "Area" properties are missing, this line sets default values of "Unknown Department" and "Unknown Area" respectively.

Inherit Default Value From Hierarchyโ€‹

You may also inherit a value from the hierarchy

In this example the Gizmo expression is trying to determine the department of a node.

If the department is not blank, it will return the department value; otherwise, it will find the first non-blank department from the ancestors of the node.

If no non-blank department is found in the ancestors, it will default to "Not Known".

node.Department.case(
is.not.blank, v => v,
node.a.Department.find(is.not.blank).defaultWith("Not Known")
)

Explanation of the script:

When we call node.Department.case(, we are checking the department of a node

If the department is not blank (is.not.blank), we return the department value (v => v)

If the department is blank, we then look for the first non-blank department among the ancestors of the node using node.a.Department.find(is.not.blank)

If no non-blank department is found, we default to "Not Known" with defaultWith("Not Known")