Portal Community
PropertyValue
Directive name (DI key)ctx
Required isolation levelSafe
ProjectContext.Services
ClassContextDirectiveService
Sub-keysenv · tenant · app · platform · user · now · today

Syntax

AtBrace (default)
{@ $ctx.sub-key.property @option }
DoubleBrace
{{ $ctx.sub-key.property }}

Complete Path Reference

env — Environment Variables

PathReturnsExample
$ctx.env.KEY_NAMEValue of the named environment variable / config key{@ $ctx.env.DATABASE_URL }Server=sql1;...
$ctx.env.SMTP_HOSTMail server hostsmtp.sendgrid.net
$ctx.env.API_BASE_URLBase URL for API callshttps://api.acme.com/v3
Config hierarchy Environment variables are read via IConfiguration, which respects the full .NET config hierarchy: appsettings.json → appsettings.{env}.json → environment variables → secrets.

tenant — Tenant Metadata

PathTypeExample value
$ctx.tenant.idNumber5
$ctx.tenant.nameStringAcme Corp
$ctx.tenant.timezoneString (IANA)Europe/Dublin
$ctx.tenant.currencyString (ISO 4217)EUR
$ctx.tenant.localeString (BCP 47)en-IE
$ctx.tenant.billingEmailStringbilling@acme.com
$ctx.tenant.hrManagerEmailStringhr@acme.com
$ctx.tenant.planStringEnterprise

app — Application Metadata

PathTypeExample value
$ctx.app.idNumber12
$ctx.app.nameStringPayroll UK
$ctx.app.codeStringpayroll-uk
$ctx.app.environmentStringProduction

platform — Platform Metadata

PathTypeExample
$ctx.platform.regionStringeu-west-1
$ctx.platform.versionString4.2.1
$ctx.platform.supportEmailStringsupport@bizfirst.ai

user — Authenticated User

PathTypeExample
$ctx.user.idNumber42
$ctx.user.nameStringAlice Smith
$ctx.user.emailStringalice@acme.com
$ctx.user.firstNameStringAlice
$ctx.user.lastNameStringSmith
$ctx.user.rolesArray["Admin","Manager"]
$ctx.user.departmentStringFinance

now / today — Date and Time

PathTypeExample
$ctx.nowString (ISO 8601 UTC)2024-03-15T10:22:01Z
$ctx.todayString (YYYY-MM-DD)2024-03-15

Options Compatibility

OptionWorks with
@uppercase @lowercase @trimAll string paths
@jsonObject/array paths (tenant, user, roles)
@date:format$ctx.now, $ctx.today
@default:valAny path that may be null
@cache @cache-thread @cache-processAll — highly recommended since context values are stable within an execution

Complex Scenarios

Scenario 1 — Locale-Aware Email Greeting

Build a greeting that addresses the user by first name, formatted for their tenant locale, with the current date in their timezone:

Email subject
{@ $ctx.user.firstName }, your {@ $ctx.tenant.name } payslip for {@ $ctx.now @date:MMMM yyyy } is ready
"Alice, your Acme Corp payslip for March 2024 is ready"

Scenario 2 — Dynamic API Base URL from Environment

HTTP Request node URL assembled from environment config + input data:

URL field (template)
{@ $ctx.env.CRM_BASE_URL @cache-process }/contacts/{@ $input.current.crmId }/notes
"https://crm.acme.com/v2/contacts/8821/notes"

Scenario 3 — Audit Log with Full Context

Structured audit log message capturing who did what, when, on which tenant:

Log message field
[{@ $ctx.now }] User {@ $ctx.user.email } (ID:{@ $ctx.user.id }) submitted {@ $var.documentType } on behalf of tenant {@ $ctx.tenant.id } via app {@ $ctx.app.name }
[2024-03-15T10:22:01Z] User alice@acme.com (ID:42) submitted Invoice on behalf of tenant 5 via app Payroll UK

Scenario 4 — Multi-Tenant Tax Rate Configuration

Instead of hardcoding rates, read them from tenant-specific environment config keys:

Tax calculation — reads per-region tax rate from config
{@ $js` const taxRateKey = "TAX_RATE_" + context.ctx.tenant.currency; const rate = context.ctx.env[taxRateKey] || "0.20"; return (context.vars.subtotal * parseFloat(rate)).toFixed(2); ` }
Reads TAX_RATE_EUR, TAX_RATE_GBP, etc. from config per tenant currency

Scenario 5 — Role-Based Conditional Routing

Use the user's roles to decide which approval tier to route to:

// IfCondition node field — checks if user has Manager role
{@ $js`
const roles = context.ctx.user.roles;
return Array.isArray(roles) && roles.includes('Manager');
` @required }

// Result: true/false → routes to Manager lane or Standard lane

Scenario 6 — Multi-Locale Date Formatting

Format the date according to the tenant locale for user-facing messages:

// UK tenant: "15 March 2024"
{@ $ctx.now @date:dd MMMM yyyy }

// US tenant: "March 15, 2024"
{@ $ctx.now @date:MMMM dd, yyyy }

// ISO for machine-readable fields
{@ $ctx.now @date:yyyy-MM-ddTHH:mm:ssZ }

Common Errors

ErrorCauseFix
PathNotFound: env.MY_VAREnvironment variable not setAdd to appsettings or environment; use @default:fallback
PathNotFound: user.departmentClaim not included in user tokenAdd the claim in the auth configuration
PathNotFound: tenant.billingEmailTenant metadata provider not returning this fieldCheck ITenantMetadataProvider implementation