Document Generation
...
Template Creation
Template - Resources
Runtime Variable
introduction a runtime variable stores a value that can be passed from a salesforce flow, generated dynamically during execution it acts as a holder for data that may be used or modified throughout the document generation it enables the flow to pass values—such as a user’s email, record id, or custom input—into the document logic at runtime 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) 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 type 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 integer in 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\<br>,\<i>, \<p>, \<ul>, \<b>) assigning values to runtime variable 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 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 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 3 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, loop over your data and assign each value to valuestring and the variable name to key, then add each to a collection