OL Learn

Variables through COTG


#1

I am looking for a simple example for how to pass variables through COTG
The examples I am coming across all seem to have Record ID set to 0

Scenario: I am printing a customer receipt that needs to be signed. I am saving the customer receipt using “CustomerNo”_“TransactionNo”.pdf to a temporary directory
I want to pass 2 variables, the customer number and the transaction number, to COTG so I can dynamically show the Receipt in COTG and then pass those variables back to my workflow so I can place the signature on the document for further processing.
My roadblock seems to be getting those variables into my COTG template
When I test the template in Designer with sample data it works fine but I cannot seem to get it to work in my workflow


#2

Hi Bronze,

You could add hidden inputs to the form and populate these fields with User Scripts. Your HTML could look something like this:

<input name="CustomerNo" type="hidden" id="CustomerNo">
<input name="TransactionNo" type="hidden" id="TransactionNo">

Create two User Scripts to copy the value of data field to these inputs. The script would prop look something like this:

Selector: #CustomerNo
Script:
results.attr(‘value’, record.fields.CustomerNo );

Selector: #TransactionNo
Script:
results.attr('value', record.fields.TransactionNo);

While testing you could set the type of the input to “text”, this way you validate if the values are written to the field.

Hope this helps,

Erik


#3

I did as you suggested and I am still running across the same issue. Works in Designer but not in my workflow.
I’m thinking the issue is around RecordID = 0 in Create Web Content in my workflow. Is there a way to determine the RecordID from the datamapping in the workflow so that I can pass that record through to my COTG form?
Unless I am way off in left field on this and there is an easier method. Then I am all ears.


#4

RecordID = 0 is most likely the problem. This generates an empty data record for rendering static web pages (e.g. no personalized data). I assume your Execute Data Mapping step outputs IDs to metadata. In that case you should be able to retrieve the first record using the following:
GetMeta(_vger_record_id[0], 10, Job.Group[0].Document[0])


#5

That worked!!
@Erik Thanks for your help