JavaScript in expressions

You can also use JavaScript to create your expressions. For example, if you want to return the lower-case version of a string, simply add toLowerCase() at the end of your value: {{name.toLowerCase()}}.

It is also possible to chain several JavaScript functions. The following expression turns the name of a person into an email address: 

{{name.replace(' ', '.').toLowerCase() + '@collibra.com'}}.

Truthiness and Falsiness

JavaScript knows the concept of "truthy" and "falsy". This differs from the strict definition where a value is only true if it evaluates to a true boolean value.

A value in Form Expressions evaluates to true if:

  • A value is the Boolean value true.
  • A value is a string, such as Product A.
  • A value contains an object, such as a date.
  • A value is a number, positive or negative, with or without fraction.
  • A value is anobject {} or an array [].

A value in Form Expression evaluates to false if:

  • A value is the Boolean value false.
  • A value is null.
  • A value is undefined.
  • A value is 0.
  • A value is an empty string, such as '' or "".

Example:

You want to change the state of an input field from disabled to enabled after selecting an asset from the asset picker. The variable defined in Value for the asset dropdown and any other dropdown component stores the ID of the selected option. 

The concept of "truthy" and "falsy" means you don't have to build a complex condition to evaluate the asset ID to true. To change the state of an input field from disabled to enabled, pass the variable of the asset picker variable to the Enabled option in the text input using expression notation.