Dynamic Values

Dynamic Values

Dynamic Values are a commonly used feature to create filters or default values that can change based on different situations. For example, you might want to show records assigned to the user who is currently logged in, or set a default value for a field based on the user’s assigned roles. Dynamic Values make it easy to do these kinds of things.

Syntax

The syntax for Dynamic Values is as follows: $DYNAMIC:<uid>. The uid should match a record in the dynamic_value table. If the uid is invalid or there is no record with that uid, the dynamic value will be empty. The same applies if an error is encountered or thrown while processing the script.

Examples

// This will always return the string "some_value".
module.exports = () => {
    return "some_value"; 
};
// This will output the UID of the currently logged-in user.
module.exports = () => {
    return $USER.getUid(); 
};
// This will output the UIDs of all active tasks, separated by a comma
module.exports = async () => {
    const activeTasks = await new Query("task").readMany("active=true");
    const activeTaskIds = activeTasks.map((task) => task.uid);
    const activeTasksCommaSeparated = activeTaskIds.join(",");
    return activeTasksCommaSeparated; 
};

Special Cases

For security considerations, Dynamic Values do not have access to the context object. This limitation does not apply for Activity Types, and you can access the current record using the following special Dynamic Values.

Dynamic ValueReturn value
$DYNAMIC:01DZZ0R300HAM52H6AReturns <uid> for the current record
$DYNAMIC:01DZZ0R300054PBC62Returns <table_name>:<uid> for the current record