Those anyone have any idea for a workaround for the following situation?
Without letting us know one of our clients who sends csv`s format for input, now wants to create a detail table from certain csv columns where each column contains multiple values delimited by “#”.
Is there a way to force a break for each value within the column in order to have a new line for each delimited value in the same cell.
Of course the initial set-up was designed for a static table, not a detailed one and now we found ourselves in the situation of client disapproving the order to be printed.
After going through documentation I have identified the following information:
record.tables.table name.addRow().
This method adds a record to an existing detail table and returns the index of the new record; see addRow(record).
record.tables.table name[index].set().
This method sets field values in one of the records in a detail table; see set(record).
With the addRow() function, passing an object is optional. When no object is passed, the function adds an empty record to the detail table.
This function always returns the index of the new record. The returned index can be used to retrieve the detail table record and set values in it.
Therefore based on the documentation and the examples provided, I have tried to apply them for my case.
CSV input datamap with the following specification:
Extract fields at root level(BAU)
Create a repeat step for the certain csv column where are multiple values delimited by “#”
Set Javascript Mode for the extracted row within the detail table
with the following code snippet :
var x = data.extract(‘tabel_asset_movable_MARK’,0).split(“#”);
for (i=0; i<x.length; i++){
var index = record.tables.detail.addRow({tabel_asset_movable_MARK: x[i]})
record.tables.detail[index].set({tabel_asset_movable_MARK: x[i]})
}
The outcome of the mentioned steps provides the desired result but still I have a persistent error, even tough values are displayed correctly in detail table.
I am attaching a sample data mapping configuration that shows how to extract multiple tokens from a single CSV field into a detail table: DynamicDetailTable.OL-datamapper (3.7 KB)
The key part is the script that extracts the detail table:
var marcas = data.extract('COLUMN2',0).split("#");
var models = data.extract('COLUMN3',0).split("#");
var dates = data.extract('COLUMN4',0).split("#");
marcas.forEach(function(m,i){
var l = i<models.length ? models[i] : "";
var d = i<dates.length ? dates[i] : "";
record.tables.Models.addRow(
{
Marca:m,
Model:l,
Date:d
});
});