Skip to main content

Get Length

Returns the number of properties in an object.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.

Inputs

  • Object - The object from which to count properties.

Options

This node does not have any options.

Outputs

  • Length - Number representing the count of properties in the object (integer).

How It Works

The Get Length node counts the number of properties in an object. When executed, the node:

  1. Receives an object through the Object input
  2. Validates that the input is a valid object and not null
  3. Counts all top-level properties in the object
  4. Outputs the count through the Length output

Requirements

  • Valid object as input (cannot be null)

Error Handling

The node will return specific errors in the following cases:

  • ErrInvalidArg - Object is null or undefined
  • ErrInvalidArg - Input is not a valid object

Usage Notes

  • Counts only top-level properties, not nested properties
  • Returns 0 for empty objects
  • Faster than getting keys and checking array length
  • Useful for quick object validation and conditional logic
  • Can be used in decision nodes to check if an object has data
  • Helpful for monitoring and logging object sizes
  • Works with any valid object structure
  • Count includes all property types (strings, numbers, objects, arrays, etc.)

Example Use Cases

Validate Object Has Data

Check if an object contains any properties:

Get Object →
Get Length →
If Length > 0 →
Process Object
Else →
Handle Empty Object

Conditional Processing

Process objects differently based on property count:

Get Object →
Get Length →
If Length > 10 →
Batch Processing
Else →
Simple Processing

Loop Control

Determine if iteration is needed:

Get Object →
Get Length →
If Length > 0 →
For Each Property →
Process
Else →
Skip Processing

Monitor Data Size

Track the size of objects in your automation:

Get Object →
Get Length →
Log Property Count →
Check Against Threshold →
Alert if Too Large

Compare Objects

Compare two objects by property count:

Object 1 → Get Length → Length1
Object 2 → Get Length → Length2
Compare Lengths → Are Equal?

Data Quality Check

Verify expected number of properties:

Get Object →
Get Length →
Expected Count = 5 →
If Length = 5 →
Valid Object
Else →
Log Error: Unexpected Property Count

Tips for Effective Use

  • Use for quick validation before processing objects
  • Combine with conditional nodes to create smart workflows
  • Helpful for error handling and data quality checks
  • More efficient than Get Keys when you only need the count
  • Use in loop conditions to verify object has data
  • Good for performance monitoring of data structures
  • Can be used to optimize processing paths based on object size
  • Useful in testing and validation scenarios
  • Store the length in a variable for reuse in multiple conditions