in one transactional PDF I’ve a single line for each record containing all data for a further process step (complement records).
This line {Metadata_begin]value1;value2;value3;value4…{Metadata_end} should be split in its contents with the leading and trailing {Metadata_begin} stripped. Best would be to export the values in separate variables or an array.
I bit messy but gets the job done. This returns an array and prints out value1,value2,value3.
var str = “{Metadata_begin}value1;value2;value3;value4{Metadata_end}”;
var str2 = str.replace(“{Metadata_begin}”,“”);
str2 = str2.replace(“{Metadata_end}”,“”);
var res = str2.split(“;”);
var myLine = "{Metadata_begin}value1;value2;value3;value4{Metadata_end}";
var myArray = myLine.match("({Metadata_begin})(.*)({Metadata_end})")[2].split(";");
Then you can access each element with myArray[0], myArray[1], etc.
It’s basically your choice: if you want to keep it simple in the Designer, then you can extract each array element in its own field in the DataMapper, that way you simply drag and drop those fields on your template in the Designer.
The easiest way to do that would be to create a record property named Metadata in your data mapping config. Set its type to Object. Then use an Action Step to store the above array in the property.
Then you can use standard extraction steps to store each element of the array into its own field (e.g. sourceRecord.properties.Metadata[0], sourceRecord.properties.Metadata[1], etc.)
But of course, you can also store the entire array in a single field (e.g. named Metadata) and then in the Designer, use JSON.parse(record.Metadata) to have access to the entire array.