OL Learn

Dynamic Images with Javascript Based On Record Count

I am trying to convert a postcard mailing to Connect, but am running into a roadblock with getting it to function. The issue is a “Label” for specific mailing procedure needs to dynamically change based on how many records I have. I’ve gone through the “How To” here: https://learn.objectiflune.com/howto/dynamic-image-with-data-from-record/ but have had no luck obviously because you can’t access the record count from the Designer. I tried even importing in an extra data field that had the record number as the value but that didn’t work either. I also tried following the “How To” on how to add fields to the DataMapper to try to capture it but it’s hard for me to follow without screenshots. Any help would be greatly appreciated :slight_smile:

You might consider doing this through the Output Preset.

With an Output Preset you’re able to add extra text, barcodes, or images onto the page. You also have access to the total number of records at that point, so you can use it to drive a condition.

Just a bit of an explanation here:

The data mapping and the merging of the extracted data onto a template can occur in parallel (through the All In One task, for instance). So when the first records are being merged onto the template, the data mapping doesn’t yet know how many records remain to be processed.

We are thinking of adding an option that would allow the DM to run in its entirety before starting to merge the data, but obviously this would have an impact on overall performance, so the option would have to be specifically selected for jobs that do not require parallel processing.

In the meantime, there are many ways you can do this, including Albert’s suggesting of going through the Output preset, which allows you to add extra content on your documents.

If that isn’t flexible enough for you, you can run the DM operation from Workflow first (thus making sure it has run in its entirety). That will store all the record IDs in the Workflow metadata. You can then store the count of all those metadata IDs in one of the process’ JobInfos, which always get passed to the Merge engine when generating a template. Then, inside your template, just refer to that JobInfo value to determine the record count.

@Phil - I’ve only been around Workflow for a couple of months, do I do not know how to run the DM operation from Workflow and how all of that works. Can you point me toward a tutorial that covers all of it?

This walk-through should help you get started: https://help.objectiflune.com/en/walkthrough-samples/workflow/