- Print
- DarkLight
- PDF
Description
Returns a specified app object's current value(s).
Can also be used to return the value of a mapped curated data element (aka. needle).
Input Parameters
Name | Type | Required | Description |
---|---|---|---|
key | Text | Yes | Target object token or name; Or, a curated Needle ID |
Returns
Type: Any
Returns the current value(s) of the specified app object.
For object types that support it, multiple values are separated using the pipe '|' character between each value.
The type of this return value will vary based on the type of the app object.
Returns (Curated Needles)
Type: Any
Returns the value of a mapped curated data element (aka. needle).
In order for this to work, mappings must exist within your app that associate your app object's source value(s) to a curated needle's value(s).
When a mapping is found, the current value of your app object is used to lookup the mapped value of the associated needle. The mapped value of the associated needle is returned.
It is important to remember that the underlying data types of your app objects do not need to match those of their associated needles. This is the beauty of mappings as it allows you to unify data retrieval (via curated needles), even when the underlying data types differ.
The type of this return value will vary based on the type of the mapped needle.
When a Needle ID is specified, the app runtime:
- Finds an associated app object
- Inspects its current value
- Looks for a curated value mapped to this current value
- Returns this curated value
- If a value mapping is not found, the specified default value is returned
Note: default values must match the data type of the specified curated needle, not the data type of your associated app object.
Only a single object can provide a mapping to any given curated needle within your app.
If multiple objects associate to the same curated needle (within the same app), the app runtime won't know which one to use when a Needle ID is specified and will just use the first one it finds, which can produce unwanted side effects.
Examples
// print the current value of object [10] to the debugger
var value = app.get("[10]");
debug.log(value);
// print the current value of object named 'firstName' to the debugger
// a default value of 'Nobody' is returned when a value is not found
var value = app.get("firstName", "Nobody");
debug.log(value);
// print the mapped value of a curated needle
// note: a mapping must exist in your app between an object and this curated needle
// note: only a single app object can provide a mapping to this curated needle
// note: a default value of false is returned when a mapping is not found
var value = app.get("Needle ID", false);
debug.log(value);
Remarks
For object types that support it, multiple values are separated using the pipe '|' character between each value.
This function uses the native app object token syntax, which refers to the ID of an object within your app that is enclosed in square brackets.
Example: [10]