OL Learn

Passing properties from the datamapper to the template

Is there a way we can set a property/value to appear on a template context from the data mapping configuration without including it in the records?

For each job we do (where job is a piece of work, not a PresConnect job) we need to set some properties at the outset that need to be included on each job. This includes a Job number and part code. This is static for each job but we might use the same template multiple times for different jobs.

Within the datamapper I can set a property based on the data filename being processed. Can this property be passed to the template in any way to allow it to be printed/rendered in a template context without adding it as a field for each record?

Hi Nick,

Why not add local variables to your Workflow process. Then in your data mapper in the preprocessor properties add properties with the same name and set their scope to automation variable. However this would require you to add a JavaScript field to one of your extraction steps and in the JavaScript Expression box you would add the code to grab that info and populate said field with the values set in your Workflow local variables.

E.G.

Workflow variables: jobNumber and partCode.

Preprocessor Properties in data mapper:

Name: jobNumber Scope: Automation Variable Type: & Default Value: Use them optionally.

Name: partCode Scope: Automation Variable Type: & Default Value: Use them optionally.

Extract Step: Add two JavaScript Variables, call one jobNumber the other partCode.

In their respective JavaScript Expression boxes you would type…

automation.variables.jobNumber;

automation.variables.partCode;

Regards,

S

One solution involves the use of a JSON file to store your job properties__.__

So in the Workflow, add as many local variables as there are job properties you want to define. In this example, I have defines the following local variables: filename, PartCode, JobNumber.

On a branch after the Input,

Add a Run Script action and set to JavasScript to set the values of the local variables:

Watch.SetVariable("filename", "\"" + Watch.ExpandString("%O") + "\"");
Watch.SetVariable("JobNumber", "\"" + "1245789" + "\"");
Watch.SetVariable("PartCode", "\"" + "ABCDEFG" + "\"");

Now add the Create File input task with the following content:

_{
"PartCode": %{PartCode}
"filename": %{filename}
"JobNumber": %{JobNumber}_

_}_

Finally, save the file to disk (Send To Folder) with the *.json extension (ex:jobProperties.json)

In the Designer, use the add your Place holders and assign them IDs

Add a script in the Scripts pane targetting either the CSS IDs or the Text placeholder or both and use the following script for instance to print the filename:

var jobProperties = loadjson('file:///C:/JSON-Example/jobProperties.json');

if(jobProperties.filename != undefined){
	results.html(jobProperties.filename);
}

https://learn.objectiflune.com/en-us/planetpress-connect/howto/passing-workflow-variables-to-designer

This page will walk you through the steps needed. (Keep in mind the name for the workflow variable and the name for the automation variable have to match. You will get an error message in the workflow reminding you, if you forget.)

SA

To replace previous broken link:
https://learn.objectiflune.com/howto/passing-workflow-variables-designer/