Description

Use this function to get the value at a specified path of an object. If the resolved value is 'undefined', the provided 'defaultValue' is returned in its place.

Syntax

get(object: PropertyPath, path, defaultValue)

Returns

Return ValueDescription
ValueReturns the resulting value obtained from the specified path in the object. If the resolved value is 'undefined', the 'defaultValue' is returned instead.

Sample

ExampleResultDescription
get({ name: 'John', age: 30 }, 'name', 'Default')'John'Returns 'John' because the 'name' property exists in the object.
get({ name: 'John', age: 30 }, 'city', 'Default')'Default'Returns 'Default' because the 'city' property does not exist in the object and the default value is provided.

Additional Example

To retrieve the "SelfEmpID" attribute from a Business Object (BO) depending on its structure:

If the BO is structured:

get(employeeInformation, "SelfEmpID")

If the BO is a list type and you want to get the attribute from the first element:

get(nth(employeeInformation, 0), "SelfEmpID")

OR

get(employeeInformation[0], "SelfEmpID")

Assuming the attribute name is: "SelfEmpID."

To view all Object functions, click here.