Using submitted COTG data in a template
When a user submits a Capture OnTheGo Form, the Workflow process that receives the data may store the information in a database and/or push it into other Workflow processes. It could, for example, send a letter or an email receipt that is personalized with the submitted data. That letter or email would need to be produced using a template that incorporates the submitted data.
Follow these steps to develop a template that uses submitted COTG data.
-
Get sample data
First, you need to get a sample of the submitted data. There are two ways to do this:-
Using the option Get Job Data File on Submit in Connect Designer; see Testing a Capture OnTheGo Template. This way you don't have to create a Workflow configuration first. Once the Job Data File is received by the Connect server, a dialog appears asking where to store it.
-
Using a Workflow configuration. When a user submits a Capture OnTheGo Form, the data are received by a Server Input task (see Workflow Help: HTTP Server Input or NodeJS Server Input) that receives and handles the submitted data. Add a Send To Folder plugin to the same process. Workflow will then output the XML file that contains the submitted data in the location specified for the Send To Folder plugin. No other tasks are needed in the process, or in the Workflow configuration.
Note: When user of the COTG app clicks or touches the Submit button in a Form, the
name
andvalue
of form elements are submitted. Normally, the name and value of an unchecked Checkbox or Radio Button would not be submitted, but in Connect, they are. Connect uses the workaround described in the following topic: Using COTG Elements.
The Form's validation should ensure that the data that the user submits is valid (see Changing a Form's validation method and How to make COTG elements required). -
-
Create a data mapping configuration
The next step is to use the sample data - an XML file - to create a data mapping configuration (see Data mapping configurations). -
Choose File > New > Data mapping Wizards > From XML file.
-
Select the XML data file as its source and click Next.
-
Set the XML Elements option to /request/values. This will automatically add an extraction step for the submitted form fields.
-
Click Finish. The file is opened in the DataMapper and the form fields are automatically extracted, including the data for the Signature and Camera object.
-
Save the data mapping configuration.
-
Create a template
Finally, create a Designer template and personalize it using the data mapping configuration (see Personalizing content). Strings, base64-encoded strings and SVG data stored in data fields using the DataMapper can be added to the template just like any other variable data (see Variable data in the text). They will show up in the template as they are. SVG data will be interpreted and displayed as an image. Strings and base64-encoded strings show up as strings. In order for a base64-encoded string to be interpreted as an image, it must be added to the URL of an image.
Adding Camera data to the template
The Camera widget submits a base64-encoded string, which can be put in a data field using the DataMapper. When this data field is dragged into a template, the string will show up in the content, instead of the image.
To make the image appear in a template, the data has to be used as the URL of an image.
The below procedure describes how to use Camera data as the source of an image inside a <div> container. The benefit of this approach is that the image automatically scales to the size of the container.
-
Click the Insert Inline Box icon on the toolbar. The Insert Inline Box dialog appears.
-
Enter an ID for the box (anything will do, as long as it helps you identify the box) and click OK. The box is added to the text flow and can be resized if needed.
<p>
Div content goes here
</p> -
Switch to the Source tab and replace the content of the box: by this text:
<img id="camera" src="" width="100%">
-
Switch back to the Design tab. You will see a small, empty rectangle inside at the top of the inline box.
-
Right-click the empty rectangle and choose New Script... in the contextual menu. The Edit Script dialog appears. The selector of the script is automatically set to the ID of the selected element (#camera).
Alternatively, you could add a new script on the Scripts pane and make sure that the Selector field is set to #camera.results.attr("src", record.fields.photo);
-
Enter the following script code: The name of the data field (in this case: photo) must be that of the Camera data in your data model.
This script updates the attribute “src” with the field containing the base64 image. -
Click OK to save the script and toggle to the Preview mode to see the result. You should see your image. When you resize the inline box that surrounds the image, the image should be resized as well.
If the inline box isn't visible, click theShow Edges button in the toolbar.