Back to all How-tos

Passing Workflow variables to Designer

This simple 2-step trick will let you get any Local and Global variables from PlanetPress Workflow into your record, for use in your template.

There’s a few ways in this it becomes super useful:

  • Using global variables defining global URLs and paths for links and resources
  • Loading different sections or snippets using a variable set in the workflow
  • Controlling object positions from Workflow (such as address block position depending on the printer)

Step 1 - Define the variable in the Preprocessor Step

Though variables are “passed on” to the data mapping task automatically, you need to declare them in your data mapping configuration for them to be useable. To do this, simply click on the Preprocessor step in the Steps pane, then look at the Properties section. Click Add Property. In the property’s definition, you need 3 important things.

  • First the name, which must correspond to the name of the variable in Workflow. Both local and global variables are called the same way, with their name as it’s displayed in the Resources pane of Workflow. Local variables have priority so if you have a local and global variable named the same, the local one is used.
  • Second, the scope which has to be set to Automation variable.
  • Third, the default value, which is useful to test your data mapping and template with just a static value that’s replaced at runtime.

Step 2: Add the value to your record

Adding a property to your record is done through a very simple script. Here’s how you do it:

  1. Open an Extraction step that is not within a loop, or create a new one.
  2. Click the Add Javascript Field button next to the Field List drop-down.
  3. In the Expression, type in the appropriate variable name preceded by automation.variables. , so if you have in automation property declared as my_var , you’d get automation.variables.my_var;
  4. Rename the field in the Order and Rename Fields dialog (next to the Field List drop-down).
  5. Save the configuration.

From this point on, the Template that uses this data mapping configuration has access to the variable added to the data model. Of course, you will only see the default value at this point, the actual value will only be available once the data mapping configuration and template run in Workflow.

Job Infos, no data mapping required
So, one last thing to note: It’s wholly possible to use JobInfos without having a data mapping configuration loaded. This is only true for Web contexts, when using 0 as the Record ID in the Create Email Contents task. However, these can only be used in Scripts, using automation.jobInfos.JobInfo1 to automation.jobInfos.JobInfo9.

Quick example

To test out this principle quickly, you can download this Workflow configuration in which you will need to import this Connect resource package. Simply drag and drop this dummy pdf file in the C:\source directory and retrieve the result named “test.pdf” in the C:\Out directory.

It simply demonstrates how the Workflow variable named “test” containing the value “yep” can be injected into the template via the data model using the method explained above.

Leave a Reply

Your email address will not be published. Required fields are marked *