GetEnv Functions
The GetEnv function retrieves environmental data during production. This allows your expressions to access information about the current job, document, record, media type, and production context. These values are determined at composition time and provide context-aware behavior in your personalization logic.
Syntax
GetEnv(constantName)
|
Parameter |
Description |
|---|---|
|
constantName |
Required. A string specifying which environment value to retrieve. Must be one of the predefined constant names listed below. |
The return type varies depending on the constant requested (String, Number, or Boolean).
Record Number Constants
These constants provide information about the current record being processed.
CurRecordNumber
Returns the sequential number of the current record being processed across the entire job.
This constant returns a Number data type.
GetEnv("CurRecordNumber")
|
Scenario |
Behavior |
|---|---|
|
Single job |
Returns 1 for first record, 2 for second, etc. |
|
Split jobs |
Numbering continues sequentially across all batches |
Examples
-
Get the current record number:
GetEnv("CurRecordNumber")
If processing the fifth record in the job:
Result: 5
-
Create a unique identifier combining job and record:
GetEnv("JobId") & "-" & GetEnv("CurRecordNumber")
If processing the fifth record and the jobid is 12345:
Result: "12345-5"
-
Add record numbering to output:
"Record " & GetEnv("CurRecordNumber")
If processing the fifth record in the job:
Result: Record 5
CurRecordNumberInBatch
Returns the number of the current record within its specific batch. For split jobs, this number restarts from 1 for each batch.
This constant returns a Number data type.
GetEnv("CurRecordNumberInBatch")
|
Scenario |
Behavior |
|---|---|
|
Single job |
Same as CurRecordNumber |
|
Split jobs |
Restarts at 1 for each split batch |
Examples
-
Get the record number within the current batch:
GetEnv("CurRecordNumberInBatch")
Result: 5 (for the fifth record in this batch)
-
Display batch-relative position:
"Item " & GetEnv("CurRecordNumberInBatch") & " in Split Part " & GetEnv("SplitPart")
Result: Item 5 in Split Part 2 (for the fifth record in the second batch)
Media Type Constants
These constants allow you to detect what type of media is being produced, enabling conditional logic based on output format.
|
Constant |
Returns True When |
Return Type |
|---|---|---|
|
GetEnv("PrintMedia") |
Producing print documents (PDF output) |
Boolean |
|
GetEnv("ProofSet") |
Producing a proof set |
Boolean |
|
GetEnv("HTMLMedia") |
Producing HTML output (on-demand, email, or HTML proof) |
Boolean |
|
GetEnv("TextMedia") |
Producing SMS or text output |
Boolean |
Examples
-
Check if producing print output:
GetEnv("PrintMedia")
Result: True (when producing print) or False (otherwise)
-
Use different image quality based on media type:
If (GetEnv("PrintMedia")) {"high_res_logo.tif"} else {"web_logo.png"}
-
Conditionally include content for print only:
If (GetEnv("PrintMedia")) {"Please keep this document for your records."} else {""}
-
Provide media-specific instructions:
If (GetEnv("HTMLMedia"))
{
"Click here to respond"
}
else If (GetEnv("TextMedia"))
{
"Reply YES to confirm"
}
else
{
"Call 1-800-555-1234 to respond"
} -
Add proof watermark only to proof sets:
If (GetEnv("ProofSet")) {"PROOF - NOT FOR PRODUCTION"} else {""}
Host Application Constant
The HostApplication constant identifies which application is executing the composition.
GetEnv("HostApplication")
This constant returns a String data type.
|
Return Value |
Description |
|---|---|
|
"uProduce" |
Running on the uProduce cross-media production server |
|
"InDesign" |
Running in uCreate (InDesign desktop application) |
|
"uPlan" |
Running in uPlan for proof set generation |
Examples
-
Detect the host application:
GetEnv("HostApplication")
Result: "uProduce"
-
Use different behavior based on environment:
If (GetEnv("HostApplication") = "uProduce")
{
"Production Server"
}
else If (GetEnv("HostApplication") = "InDesign")
{
"Desktop Preview"
}
else
{
"Proof Generation"
} -
Enable debug information only in desktop preview:
If (GetEnv("HostApplication") = "InDesign")
{
"[DEBUG: Record " & GetEnv("CurRecordNumber") & "]"
}
else
{
""
}
Job Information Constants
These constants provide information about the current job and its relationship to other jobs.
|
Constant |
Description |
Return Type |
|---|---|---|
|
GetEnv("JobId") |
The unique identifier of the current job |
String |
|
GetEnv("ParentJobId") |
The parent job ID for turbo/split jobs (jobs spawned from another job) |
String |
|
GetEnv("TopMostJobId") |
The primary job ID; returns parent job ID if this is a turbo/split job, otherwise returns current job ID |
String |
|
GetEnv("SplitPart") |
The current split part number for jobs that are split into multiple batches |
Number |
Examples
-
Get the current job ID:
GetEnv("JobId")
Result: "12345"
-
Create a tracking code using job information:
GetEnv("TopMostJobId") & "-" & GetEnv("SplitPart") & "-" & GetEnv("CurRecordNumber")
Result: "12345-2-150" (Job 12345, Split Part 2, Record 150)
-
Include job reference in output:
"Reference: JOB-" & GetEnv("JobId")
Result: "Reference: JOB-12345"
-
Display split information:
"Processing batch " & GetEnv("SplitPart")
Job Type Constant
The JobType constant identifies the type of job being executed.
GetEnv("JobType")
This constant returns a String data type.
|
Return Value |
Description |
|---|---|
|
"PRINT" |
Standard print production job |
|
"PROOF" |
Proof job (lower quality preview) |
|
"PROOF_SET" |
Proof set generation |
|
"ON_DEMAND" |
On-demand (real-time) production |
|
"RECORD_SET" |
Record set export |
|
"FLAT" |
Flat data export (evaluated content object values) |
|
"EMAIL_MARKETING" |
Email marketing campaign |
|
"EMAIL_MARKETING_TEST" |
Test email for marketing campaign |
Examples
-
Get the job type:
GetEnv("JobType")
Result: "PRINT"
-
Add watermark for non-production jobs:
If (GetEnv("JobType") = "PROOF" Or GetEnv("JobType") = "PROOF_SET")
{
"PROOF COPY"
}
else
{
""
} -
Conditional content for email vs print:
If (GetEnv("JobType") = "EMAIL_MARKETING" Or GetEnv("JobType") = "EMAIL_MARKETING_TEST")
{
"Click here to unsubscribe"
}
else
{
""
} -
Handle test emails differently:
If (GetEnv("JobType") = "EMAIL_MARKETING_TEST")
{
"[TEST EMAIL] "
}
else
{
""
} & "Your Monthly Newsletter"
Document Property Constants
These constants provide information about the document being composed.
|
Constant |
Description |
Return Type |
|---|---|---|
|
GetEnv("DocumentName") |
The name of the document as specified in the job ticket |
String |
|
GetEnv("DocumentID") |
The unique identifier of the document |
String |
|
GetEnv("DocumentType") |
The type of document being composed |
String |
DocumentType Values
|
Value |
Description |
|---|---|
|
"HTML" |
HTML document |
|
"INDD" |
InDesign document |
|
"TXT" |
Text document |
|
"XLIM" |
XLIM document |
Examples
-
Get the document name:
GetEnv("DocumentName")
Result: "Monthly Statement"
-
Include document reference in footer:
"Document: " & GetEnv("DocumentName") & " (ID: " & GetEnv("DocumentID") & ")"
-
Conditional behavior based on document type:
If (GetEnv("DocumentType") = "HTML")
{
"<br>"
}
else
{
Chr(10)
}
Production Context Constants
These constants provide additional context about the production environment and configuration.
|
Constant |
Description |
Return Type |
|---|---|---|
|
GetEnv("InstanceID") |
The template instance identifier |
String |
|
GetEnv("BaseURL") |
The base URL of the website |
String |
|
GetEnv("BaseOnlineDocURL") |
The base URL for on-demand PDF documents |
String |
|
GetEnv("CircleTouchpointFriendlyID") |
The friendly identifier of the Circle campaign touchpoint |
String |
|
GetEnv("RecipientFilter") |
The filter used to select recipients (table name, plan filter, or query) |
String |
|
GetEnv("HotFolderFileName") |
The name of the file that triggered a hot folder job (empty if not hot-folder triggered) |
String |
Examples
-
Get the base URL for building links:
GetEnv("BaseURL")
Result: "https://www.example.com"
-
Build a personalized URL:
GetEnv("BaseURL") & "/offer/" & |->[RecipientKey]
Result: "https://www.example.com/offer/ABC123"
-
Create a link to an on-demand PDF:
GetEnv("BaseOnlineDocURL") & "?id=" & |->[CustomerID]
-
Check if job was triggered by hot folder:
If (GetEnv("HotFolderFileName") != "")
{
"Triggered by: " & GetEnv("HotFolderFileName")
}
else
{
"Manual submission"
} -
Include touchpoint reference for tracking:
"Touchpoint: " & GetEnv("CircleTouchpointFriendlyID")
-
Log the recipient filter used:
"Filter: " & GetEnv("RecipientFilter")
Note: Some constants may return empty strings or default values depending on the production context. For example, HotFolderFileName is empty when the job was not triggered by a hot folder, and ParentJobId may be empty for non-turbo/split jobs.
More topics
-
Conversion Functions - Functions for converting between data types
-
Numeric Functions - Functions for mathematical operations
-
String Functions - Functions for text manipulation
-
Date Functions - Functions for date and time operations
-
Asset Functions - Functions for working with assets