OL Learn

Duplication record output based on a field value

Hi
I’m would like to duplicate output records based on a field value within the data using the DataMapper

Many thanks
Joe

Use the record.copies property in the DataMapper. See the online help.

Thanks Phil, sorry it’s taken me so long to get back to you.

Joe

Hi Phil,

How can I the same rule to work with xml?

I get the error message ‘Wrapped java.lang.IllegalArgumentException: Number of copies cannot be less than 1’ in my Action.

Below is a screen grab for reference:

Ideally I would like to extract a variable from the Json data if possible.

Many thanks
Joe

Sorry, or alternatively is there a way to set the output quantity of a pdf page using a variable record within an xml data?

Thanks
Joe

Your screenshot shows that you’re using an invalid syntax for the data.extract() command.
It should instead look like this:

data.extract("./item[1]/kbatch");

or

data.extract("/root/item[1]/kbatch");

As for extracting a value included in a JSON string that comes from the data, you would use something like this (assuming the JSON field is also named “copies”):

var jsonFld = data.extract("./item[1]/json_data");
var myJson = JSON.parse(jsonFld);
record.copies=myJson.copies;

Hi Phil,

That’s great, thanks very much for this. It works perfectly in my Data Mapper which I can then use in my workflow.

Thanks
Joe

Hi Phil,

Finally I have a xml file with a url link to pick up pdf’s for processing but would like to add a way to duplicate the pdf’s by a variable value within the data.
Is this possible within Workflow without using a Data Mapper and Connect Design?

If just using Workflow isn’t a viable way, how might I do this using the Data Mapper in conjugation with Connect Design in Workflow?

Any help would be greatly appreciated.

Thanks
Joe

Sorry for the delay, I was off last week.

Not quite sure I understand the request, but from what I’m gathering, each record copy should refer to its own unique PDF. This could be done through the DataMapper, assuming it has access to the PDF files but it also means you’d have to implement a naming scheme for each PDF copy to prevent name-collisions, and you’d then have to store that new name in each record in your data model.

If the DataMapper doesn’t have access to the PDF files, then you’ll have to use Workflow to do it but that means Workflow will also have to modify the XML data file to contain the actual names of the duplicated PDFs.

All in all, this is not a mundane task. I would advise you to get in touch with our professional services crew to see of they could help you implement the procedure.

Hi Phil,

No problem with the delay in replying, :wink:

How about if I used a ‘Loop’ module using a ‘quantity’ field to loop through the number of times needed for each pdf?

Many thanks
Joe

Sure… but you still need to make sure to give a unique name to each PDF and to record that name in the data file that eventually goes to the DataMapper.

Okay, I should be able to use a URN from the data for naming.
I’ll let you know how I get on once I have some data.
Thanks again
Joe