Objectif Lune joins Upland Software.Learn more >

Back to all How-tos

Add a Record Index and Count to your document

While Designer has integrated methods of displaying page numbers, sometimes you want to know a little more. In this short How-To we’ll show you how to get the current record index, and the total number of records in the record set, displayed on your document.

You can use the following Connect resource package to get started.

Step 1 - Creating the Record Count field in Connect Designer

The Record count is part of the Metadata generated by the Execute Data Mapping task in Workflow. In order to get it into Connect Designer, you’ll have to create an empty field called RecordCount in your Data Mapping Configuration and complement it with the record count value from Workflow.

  1. Right-click on the record header and click Add Field.
  2. Enter a name for the field, for example RecordCount.
  3. Right-click on the new field and choose Set type and select String (all metadata fields are strings).
  4. Right-click again on the field and choose Default Value. Put in a default value that would correspond for what you want for this field.

Step 2 - Getting the Record Index

The Record Index is something you can grab from the Data Mapping Configuration, in a very straightforward manner. To do this:

  1. Create a new field called RecordIndex
  2. In an existing Extract step (ideally outside of a loop), add a new JavaScript extract field
  3. Enter record.index; in the JavaScript box.

Step 3 - Putting it all together in Designer

Since you now have 2 fields in your data model, adding this anywhere in Designer is fairly straightforward. Here’s an example where a span or div called recordData contains Record: x of n when the job is processed through Workflow:

Step 4- Making it work in Workflow

Now, the empty field called RecordCount we created at Step 1 must be complemented from Workflow using a Metadata Fields Management task. A detailed article on this topic is available here: Complement records using metadata.

In summary, here are the tasks used to create the Workflow process you need:

  1. An Execute Data Mapping task using the configuration we built in the steps above.
  2. A Metadata Fields Management task configured as follows:
    • under Action, select Add.
    • under Field information choose:
      • Level: Document
      • Field name: _vger_fld_RecordCount
      • Make sure you have Metadata available by choosing the input data file in Debug > Select and stepping through the Execute Data Mapping task.
      • Field value: Right click and choose Get Metadata Location…
      • Specifically, the data you want is located in the metadata under Job > Group, in the Product Information. The field is called Number of Documents in Group.
  3. A Create Print Content task using the aforementioned Designer template.
  4. A Create Job task using the Default preset.
  5. A Create Output task containing a Generic PDF preset.

Solution

Here is a Connect resource package and a Workflow configuration along with the corresponding input data file which demonstrate this principle.

Tags
workflow

Leave a Reply

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