You can set a default value or override it with field data or constants. Runtime Variables are ideal for passing values from flows, filtering or selecting records conditionally, and driving template decisions (e.g., showing/hiding sections) using flow action Generate Document.
Single Runtime Variable
To create a Variable, follow the steps below -
- Click 'Resources'; the Resource Manager opens up.
- In the 'New Resource' pane, select Resource type from the drop-down as 'Runtime Variable'.
- Enter a Label, and the API Name will automatically populate.
- Assign a Value Type based on your requirement such as String, Integer, Double, etc.
- You can assign Default Value if needed.

Value Types
Value types should be selected based on the field type or variable type available in the Salesforce Flow from which the value is passed.
String:
All text-based fields from Salesforce can be passed as strings.
Examples: RecordId, Text, Pickist, Textarea, Email, URL, Phone
Integer:
All number fields without decimals can be passed in as integers.
Examples: Number, Phone, any field declared as Integerin Salesforce.
Double:
All numeric fields that allow decimal values can be passed as doubles.
Examples: Currency, Percent, Number(with Decimals)
Boolean:
True/False fields can be passed as Boolean values. This includes any Checkbox values from a Screen Flow or Boolean fields from Salesforce records. Examples: Checkbox
Date:
Fields that store only the calendar date (without time) can be passed as Date.
DateTime:
Fields containing both date and time components should be passed as DateTime.
Examples: CreatedDate, LastModifiedDate - Datetime
Time:
Fields that store only time (without date) can be passed as Time
Rich Text Area:
Fields storing formatted text content can be passed in as Rich Text, which includes styling such as bold, italic, and underline; paragraph formatting like line breaks, bullet points, and numbered lists; embedded hyperlinks; and basic HTML tags (e.g
,,
,
- , ).
Use Case - Single variable
1. Pass Email from Flow to Document
Goal: Dynamically display user-specific data—such as the email ID—by passing it from a Salesforce Flow into the CloudFiles Template during document generation.
To achieve this, begin by defining a Runtime Variable of type String in the CloudFiles Template through the New Resource pane. Then, within your Salesforce Flow, create a flow variable with Apex-Defined type and choose the class 'cldfs_CloudFilesVariable'.
Set the following fields in the Assignment step of the Flow:
- key: This should match the API name of the Runtime Variable in the template.
- valueString: This holds the value you wish to pass (e.g., an email or name). You can assign the value from the screen input element 'Email'.
Once set, the Runtime Variable will carry the Flow-provided value into the document generation process, allowing the content to reflect dynamic runtime data.
2. Fetch a Record Using Runtime Variable
Goal: Use a Runtime Variable to fetch a specific record dynamically based on input (such as an email address) provided from a Salesforce Flow.
To dynamically fetch a single Contact record, a Runtime Variable can be created in the CloudFiles template to hold the Contact’s email address, which is passed as input from a Salesforce Flow. This enables Document Generation to use the provided email to filter and retrieve the matching Contact record (Record Single Variable). A CloudFiles variable in the Flow is used to pass this email value at runtime. Once the record is fetched, its fields can be dynamically merged into a document template for personalized document generation.
Assigning Value in Flow
- Create a variable of data type Apex-Defined, and select the Apex class as 'cldfs_CloudFilesVariable'

2. This variable has key and valueString as parameters, which must be assigned using the Assignment element in the flow.
- key is the API name of the Runtime Variable as defined in the CloudFiles template.
- valueString is the actual value you want to assign and pass to the Runtime Variable at runtime.
- Add it to the collection variable

Use the cldfs_variables as the Flow action (Generate Document) input - CloudFiles Variables.
Collection Runtime Variable
To store and pass multiple runtime values, enable the Allow multiple values option while creating the Runtime Variable in the template. This option allows the variable to hold a list of values rather than just one, so that multiple entries can be assigned and processed during flow execution. This is useful when you expect repeated or grouped inputs from Salesforce Flows, such as lists of names, or other dynamic content that needs to appear in loops or tables within the document.
Use Case - Collection
Passing Runtime Variable collection from Flow
Goal: Display a list of values, such as multiple product names, by passing a collection from a Salesforce Flow into a CloudFiles document.
Enable "Allow multiple values" while creating a Runtime Variable in the template. In Flow, assign each item’s value to valueString, add that variable to a CloudFiles collection variable, and then map the entire collection to valueCollection (after defining the key).
Refer to the callout below for detailed steps on how to configure Flow variables to assign values to display them dynamically in a loop or table within the document.
Assigning Values in Flow
In the CloudFiles template, create a Runtime Variable of type String with Allow multiple values enabled.

To pass a list of items (e.g., products) into this Runtime Variable, configure the following Apex-defined Flow variables (Apex Class: cldfs_CloudFilesVariable):
- var_ProductSingle – to hold one item at a time.

- var_ProductCollection – to gather all items.

- var_ProductList – to map the values to the Runtime Variable defined in the template.

Use an Assignment element to build the collection:
- Set the current product value on the single variable:
- Add that single variable into the collection:

Repeat this step for each product (manually or inside a Flow Loop).

Use another Assignment element to map the collection to the template variable:
- Set the key to the Runtime Variable API Name:
- Assign the collected values:

Add var_ProductList to the CloudFiles Variable collection used as the Flow action input - CloudFiles Variables.