Import CSV Multirow Has The Same Value after SetValue on PreCreate
Import CSV Multirow Has The Same Value after SetValue on PreCreate
Showa Indonesia Mfg
Posts: 7Questions: 3Answers: 0
Description of problem:
Programming language: PHP
I'm using import csv via datatable and need process in some column before insert to table. The process is to get Description by Part No.
But when using the preCreate event, the inserted description value is always the same value for all rows. It seems like the setValue() is updating all rows with the last value get by getPartInfo() function.
Is there any solution ?
Code
->on('preCreate', function($editor, &$values) {
$partInfo = $this->getPartInfo($values['PART_NO'], $values['CONTRACT']);
$editor
->field('DESCRIPTION')
->setValue($partInfo['Description']);
Result
This question has an accepted answers - jump to answer
Answers
That is correct. It sets the value to use for the field, and that is applied to the field instance, rather than at a row level.
What to do here is modify the value in the
$values
array (since it is passed by reference, as noted by the&
) - so you can do:Allan
Great, solved!
Thank you for your support.