Multiple values in one csv column

Hello OL Experts!

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 “#”.

image

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.

Any help would be much appreciated.

Best,
Alexandru

We covered this use case in this blog article from last year.

Hi and thanks for you swift reply @Phil,

I have read it already but, unfortunately, I’m not seeing a way of applying in my situation… because my data looks something like this:

Record 1 : |“value”|“value”|“value”|“value”|“value#value”|

Record 2 : |“value”|“value”|“value”|“value”|“value#value#value”|

Record 3:|“value”|“value”|“value”|“value”|“value”|

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.

  1. CSV input datamap with the following specification:
    image

  2. Extract fields at root level(BAU)

  3. Create a repeat step for the certain csv column where are multiple values delimited by “#”

  4. Created a table based on this note:

  5. Set Javascript Mode for the extracted row within the detail table
    image

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.

image

image

image

image

Any help or guidance would be much appreciated!

Thank you have a nice weekend!

Here is what I do when I use addRow() and set().

I create a first record and set each fields with dummy values.

Then in my loop, I affect the first extraction to replace the previously created first dummy record.
then I add new records.

Can you post an example? I still get the error…

Can you post a package of your Template/Datamapper? Anonymized of course :wink:
If not, contact me in private and send me the original, I will look into it.

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
		});
});
1 Like