Hi everyone, I’m trying to configure a spreadsheet import process where I need to read some columns from the spreadsheet but also automatically fill another field with the Master table ID.
Scenario:
-
I have a Master table:
Trainings
. -
I have a Detail table:
Students
(linked byId_Treinamento
). -
I need to import a spreadsheet with a single column containing the student codes.
-
During import, I want the field
Id_Treinamento
to be automatically set with the Master record ID that is currently open.
I believe I already understand the logic, but I can’t figure out how to properly retrieve the Master ID inside the Row_Import
event.
Here’s what I tried:
// Page Importing event
function Page_Importing(object &$builder, array &$options): bool
{
$options["headerRowNumber"] = -1;
$options["headers"] = ["Colaborador","Id_Treinamento"];
return true;
}
// Row Import event
function Row_Import(array &$row, int $count): bool
{
// Attempts to get the Master ID:
#$masterId = $this->getCurrentMasterIDValue("Id_Treinamento");
#$masterId = Page("TbTreinamentos")->ID->CurrentValue;
#$masterId = $this->getCurrentMasterTable();
#$masterId = $GLOBAL["tb_Treinamentos"]->ID->CurrentValue;
$row["Id_Treinamento"] = $masterId;
return true;
}
All these attempts failed, I couldn’t get the Master table ID correctly.
Has anyone faced this situation before? What’s the correct way to retrieve the Master ID inside the
Row_Import
event?
Thanks in advance for the help!