Skip to main content

Variables

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.

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:

VariableDescriptionExample Output
{{SID}}System identifier of the current recordabc123xyz
{{UID}}Unique identifier of the current recordEXP-001
{{NAME}}Name of the current recordMy Experiment
{{DESCRIPTION}}Description of the current recordTesting compound efficacy
{{DESCRIPTION:<CODE>}}Description of the current record processed through custom codeProcessed description
{{PROJECTS}}Projects associated with the current recordProject data array
{{OWNER.SID}}System identifier of the record owneruser456
{{OWNER.NAME}}Name of the record ownerJohn Doe
{{DATECREATED}}Date and time the record was created2026-03-17 10:30:00
{{VERSION}}Version number of the current record3
{{LINK}}Direct link to the record's detail viewFull URL to record
{{SHARABLELINK:<URL>}}Sharable link for external accessFormatted sharable URL
warning

For {{SHARABLELINK:<URL>}}, the URL must contain an api_key parameter to allow access by users without Labii authentication.

URL Variables​

Access information about the current page URL:

VariableDescriptionExample Output
{{URL}}Complete current URLhttps://labii.com/records/123
{{DOMAINFRONTEND}}Current data center domainhttps://labii.com
{{DOMAINCURRENT}}Current domainhttps://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
    • JavaScript: Use Moment.js format patterns
      • Example: {{CURRENT:MMMM Do YYYY, h:mm:ss a}} → March 17th 2026, 2:30:45 pm
    • Python: Use Strftime format codes
      • Example: {{CURRENT:%B %d, %Y}} → March 17, 2026

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
info

JavaScript: Supports custom formatting using Moment.js 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:

{{nqtw0a40x1d58puzEJOTY:parseInt(data)}} // Convert to integer
{{column_sid:parseFloat(data)}} // Convert to float
{{column_sid:data.toUpperCase()}} // Convert to uppercase
{{column_sid:data * 2}} // Multiply by 2
{{column_sid:data.length}} // Get string/array length

Built-in Statistical Functions:

FunctionDescriptionUsage Example
sumCalculate sum of number array{{column_sid:sum(data)}}
meanCalculate mean (average){{column_sid:mean(data)}}
seCalculate standard error{{column_sid:se(data)}}
sdCalculate standard deviation{{column_sid:sd(data)}}
encodeStringForURLURL-encode a string{{column_sid:encodeStringForURL(data)}}
decodeStringFromURLURL-decode a string{{column_sid:decodeStringFromURL(data)}}
LabiiAccess Labii utility functions{{column_sid:Labii.functionName(data)}}

Complex Examples:

// Calculate average and round to 2 decimal places
{{column_sid:mean(data).toFixed(2)}}

// Get sum and format with units
{{column_sid:sum(data) + ' mg'}}

// Conditional formatting
{{column_sid:data > 100 ? 'High' : 'Low'}}

Python Processing​

Access nested dictionary values using dot notation to specify keys:

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

Examples:

{{nqtw0a40x1d58puzEJOTY:user.sid}} // Access user.sid from column data
{{column_sid:metadata.created_by}} // Access nested created_by field
{{column_sid:results.concentration}} // Access concentration in results
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:

VariableDescriptionExample Output
{{USER.SID}}System identifier of current useruser789
{{USER.NAME}}Full name of current userJane 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:

{
"label": "{{API_KEY}}",
"value": "sk_live_abc123xyz789"
}

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
tip

Best Practice: Store sensitive values like API keys as metadata at the organization level, then reference them using variables. This centralizes management and improves security.

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)
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​

Experiment {{UID}} - {{NAME}} (Version {{VERSION}})

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

Example 2: Date Range Query​

Records from {{-30DAY}} to {{TODAY}}

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

{{SHARABLELINK:{{DOMAINFRONTEND}}/api/records/{{SID}}/?api_key={{API_KEY}}}}

Output: Complete sharable URL with authentication

Example 4: Statistical Summary​

Mean Concentration: {{concentration_column_sid:mean(data).toFixed(2)}} μM
Standard Deviation: {{concentration_column_sid:sd(data).toFixed(2)}} μM

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