Is someone able to explain me “data”, “sourceRecords” and “automation” in the properties of the preprocessor ?
In the datamapper, I need to store data in a global variable to use it later.
In other words I read a file line by line. When I read a line with a customs code, I need to store this code and use it each time I read an item code.
So when I read the customs code I store it with “data.properties.HSNCode = data.extract(29,36,0,1);”. Of course, I’ve declared before the variable in the preprocessor. Later, when I read an item code I add a field with javascript “data.properties.HSNCode.toString();” to affect the customs code in the datamodel, in order to get the structure itemCode, customsCode, description, etc …
The problem is: no data is got into the datamapper
Due to the nature of how data is processed in automation, this is a difficult one. When automation kicks in, your job may be split into multiple batches and processed separately, meaning each of these batches would not have access to the properties of the other. While this enables multithreading and parallel processing, it prevents the sort of thing you’re trying to do within the confines of the DataMapper.
A workaround for this would be to write the HSNCode to a file directly on the disk, and retrieve that information at the beginning of each record. However, this might affect performance because you cause a read/write on each record… And if multithreading occurs, this will cause conflicts since multiple batches are trying to read/write to the file simultaneously.
I’m sorry if I cannot be more help in this particular situation, I will refer to the R&D team to see if there’s a better solution for you.
If you use Workflow, you could just pass the information through a JobInfo or a local process variable.
Alternatively, you could write a preprocessing script for the Datamapper that reads the file and stores the value in a data property, which you can then access any time when the data mapping operation is executed.
In the preprocessor: declare a property HSNCode in the scope “sourceRecord”.
In the datamapper, when I meet the HSNCode, use an action set up with “setPropertie” and affect HSNCode with the extraction done.
Still in the datamapper, when I read an item line, add a field HSNCode in the datamodel, in the detail table. In the extraction step affect the HSNCode of the datamodel with the HSNCode of the preprocessor.
I’m looking for same resolution for same reason and if wondering if there is better options now after 7 years? Workaround suggested by @Evie works for me but it’s true the performance suffers
Since then, runtime parameters have been introduced. You simply declare them in your data mapping configuration, and OL Connect Workflow will be able to provide a value dynamically at run time.