Lowdefy
v3.23.3/Operators/_get/

_get

(arguments: {
  from: any[] | object,
  key: string | integer,
  default?: any,
}): any

The _get operator gets a value from the object or array specified in from. If the key is not found, the provided default, or null if not specified, are returned.

Arguments

object
  • from: any[] | object: Required - The object to get the value from.
  • key: string: Required - The value of the key or array index to get from the from object or array. If the value is not found, null, or the specified default value is returned. Dot notation and block list indexes are supported.
  • default: any: A value to return if the key is not found in from. By default, null is returned if a value is not found.

Examples

Get the value of a key from an object:
_get:
  from:
    name: George
    age: 22
  key: name

Returns: "George".

Use _get to as a switch statement to choose an Icon name:
_get:
  key:
    _state: status
  from:
    new: PlusCircleTwoTone
    escalated: ExclamationCircleOutlined
    investigation_started: ToolTwoTone
    client_contacted: SoundTwoTone
    awaiting_confirmation: LikeOutlined
    closed: StopOutlined

Returns: The icon corresponding to the status in state.

Get from an array (arrays are 0 indexed):
_get:
  from:
    - id: 1
      name: Joe
    - id: 2
      Name: Dave
  key: 0.name

Returns: 1.

Dot notation:
_get:
  from:
    my_object:
      subfield: 'Value'
  key: my_object.subfield

Returns: "Value".

Return a default value if the value is not found:
_get:
  from:
    value1: 1
  key: value2
  default: 99

Returns: 99.

Block list indices:

Assuming state:

 _get:
  from:
    my_array:
      - value: 0
      - value: 1
      - value: 2
  key: my_array.$.value

Returns: 0 when used from the first block (0th index) in a list.