codeVariables

Use variables as dynamic placeholders to substitute specific values within parameters

Overview

Labii variables are dynamic placeholders that enable you to substitute specific values within parameters automatically. Variables streamline data management by allowing you to create reusable templates and configurations that adapt to different contexts without manual reconfiguration. This powerful feature enhances automation, reduces errors, and improves productivity in laboratory workflows.

circle-info

Variables are enclosed in double curly braces: {{VARIABLE_NAME}}. They are automatically replaced with their corresponding values when processed.

Record Properties

Access properties of the current record using these variables:

Variable
Description
Example Output

{{SID}}

System identifier of the current record

abc123xyz

{{UID}}

Unique identifier of the current record

EXP-001

{{NAME}}

Name of the current record

My Experiment

{{DESCRIPTION}}

Description of the current record

Testing compound efficacy

{{PROJECTS}}

Projects associated with the current record

Project data array

{{OWNER.SID}}

System identifier of the record owner

user456

{{OWNER.NAME}}

Name of the record owner

John Doe

{{DATECREATED}}

Date and time the record was created

2026-03-17 10:30:00

{{VERSION}}

Version number of the current record

3

{{LINK}}

Direct link to the record's detail view

Full URL to record

{{SHARABLELINK:<URL>}}

Sharable link for external access

Formatted sharable URL

circle-exclamation

URL Variables

Access information about the current page URL:

Variable
Description
Example Output

{{URL}}

Complete current URL

https://labii.com/records/123

{{DOMAINFRONTEND}}

Current domain

https://labii.com

Date Variables

Generate dynamic dates for time-sensitive operations:

Current Date

  • {{TODAY}} - Returns today's date in YYYY-MM-DD format

    • Example: 2026-03-17

Formatted Current Date/Time

  • {{CURRENT:<FORMAT>}} - Returns current date/time with custom formatting

Relative Dates

Calculate dates relative to today using the pattern: {{[+/-][#][DAY/WEEK/MONTH/YEAR]:<FORMAT>}}

Syntax:

  • + or -: Add or subtract time

  • #: Number of units (1, 2, 3, etc.)

  • Unit: DAY, WEEK, MONTH, or YEAR

  • <FORMAT>: Optional format (defaults to YYYY-MM-DD)

Examples:

  • {{-5WEEK}} - 5 weeks ago → 2026-02-10

  • {{+30DAY}} - 30 days from now → 2026-04-16

  • {{-1YEAR:YYYY}} - Year value from 1 year ago → 2025

  • {{+2MONTH:MMM YYYY}} - 2 months from now → May 2026

circle-info

JavaScript: Supports custom formatting using Moment.jsarrow-up-right patterns Python: Format support is currently not available for relative dates; returns YYYY-MM-DD format only

Column Variables

Reference and process data from table columns:

Basic Column Reference

  • {{[COLUMN_SID]}} - Returns the value of a column using its SID

    • Example: {{nqtw0a40x1d58puzEJOTY}} returns the column's stored value

Processed Column Values

  • {{[COLUMN_SID]:<CODE>}} - Returns column value processed through custom code

JavaScript Processing

Execute any JavaScript code to transform column data. The column value is available as the data variable.

Basic Operations:

Built-in Statistical Functions:

Function
Description
Usage Example

sum

Calculate sum of number array

{{column_sid:sum(data)}}

mean

Calculate mean (average)

{{column_sid:mean(data)}}

se

Calculate standard error

{{column_sid:se(data)}}

sd

Calculate standard deviation

{{column_sid:sd(data)}}

encodeStringForURL

URL-encode a string

{{column_sid:encodeStringForURL(data)}}

decodeStringFromURL

URL-decode a string

{{column_sid:decodeStringFromURL(data)}}

Labii

Access Labii utility functions

{{column_sid:Labii.functionName(data)}}

Complex Examples:

Python Processing

Access nested dictionary values using dot notation to specify keys:

Syntax: {{[COLUMN_SID]:key1.key2.key3}}

Examples:

circle-info

Python code processing is limited to dictionary key access only. Full Python expressions are not supported.

User Variables

Access information about the current logged-in user:

Variable
Description
Example Output

{{USER.SID}}

System identifier of current user

user789

{{USER.NAME}}

Full name of current user

Jane Smith

Metadata Variables

Use metadata labels as variables to dynamically reference organization-level or project-level settings:

Syntax: Define metadata with labels wrapped in {{...}}, then reference them as variables.

Example:

Once defined, use {{API_KEY}} anywhere to substitute the value automatically.

Common Use Cases:

  • Store shared API keys for generating sharable links

  • Define organization-wide constants

  • Maintain environment-specific configuration values

  • Reference project-specific parameters

circle-check

Escaping Variables

To prevent a string from being interpreted as a variable, escape the curly braces with backslashes:

Escaped Format: \\{\\{string\\}\\}

Example:

  • Without escaping: {{TEST}} → Replaced with TEST variable value

  • With escaping: \\{\\{TEST\\}\\} → Displays as {{TEST}} (literal text)

circle-info

Use escaping when you need to display variable syntax as literal text in documentation or when the curly braces are part of your actual data format.

Usage Examples

Example 1: Dynamic Record Title

Output: Experiment EXP-001 - Compound Testing (Version 3)

Example 2: Date Range Query

Output: Records from 2026-02-15 to 2026-03-17

Output: Complete sharable URL with authentication

Example 4: Statistical Summary

Output: Mean Concentration: 45.67 μM, Standard Deviation: 3.21 μM

Last updated