OL Learn

How to let Worlfkow know, that particular picture file was used in the Template

Dear Sirs.

I have a problem for which I can’t find a solution for. The customer would like us to prepare a solution for generating product flashcards PDF files. One of the requirements is that we should generate a flashcard of particular product, if the customer updated a picture assigned to this product. The problem is that in data, which we receive from customer’s system, pictures are not assigned to particular products, but to the whole family of products. Please take a look at the example below:

“data”: [
“type”: “flashcard-merchandising-families”,
“id”: “1”,
“attributes”: {
“id”: 0,
“pictograms”: [
{ “name”: “pict1.svg”, “url”: “/api/pictogram/0944287F-CE4F-4E5F-B5B4-C849628415A2”, “date”: “2021-10-04T09:35:20+02:00” }
“products”: [
“reference”: 42424242, “name”: “Example of product name”, “image_url”: “http://gallery2/photo.php?r=82304822&h=1000&w=1000”,
“nomenclature”: {
“division”: { “id”: 1, “name”: “name” },
“subdivision”: { “id”: 1, “name”: “name” },
“type”: { “id”: 1, “name”: “name” },
“subtype”: { “id”: 1, “name”: “name” }
“characteristics”: [
{ “id”: “ATT_01746”, “value”: “Gray” }

One family can have multiple products, but from the data we can’t determine which products use which pictograms. It’s defined only at the document template level. Moreover the picture name or path is not passed in record data. They will will be “pointed” directly by template creator.

The problem is that I don’t know how to determine which product flashcards to generate after particular pictogram was updated. I can’t do it in workflow before data mapping and output creation, because (as shown in example) data doesn’t contain information about the picture-product relation. I tried to return the information from the template by updating records in standard script of dynamic picture, for example inserting the information into ExtraData field (because this is the moment where I know which picture is inserted into document), but it seems that records are read-only at the moment. It seems that I’m also unable to return any information to job info variables - they also seem to be read-only.

Is there any way for the workflow to know, which pictures was used in templates or to return the information that particular picture was used from the template to workflow? I can’t see any other way how could we decide which product flashcard should be generated, because of picture update.

I will be very grateful for any hints.

Unfortunately you cannot update the data from the template. But as you already have the picture info you could try writing it to a custom property on the content item created for each record in the Connect database.

See: https://help.objectiflune.com/en/planetpress-connect-user-guide/2021.2/#designer/API/contentitem_Object.htm

So in Post Pagination script you could write something like this:
contentitem.properties.pictureInfo = JSON.stringify( pictureInfo );

This can can be retrieved in Workflow using the Retrieve items plugin. First you’ll need to retrieve the content set based on the ID in the metadata (generated by the Create Print Content task).

Subsequently iterate over the content items in the metadata to fetch their properties (again using Retrieve items).

Hello Erik.

Thank you very much for help. It seems, that this idea will work for me.

Best regards.

1 Like