I have a simple import use case to import from the following excel file
The employeeProfle field is also an entity for which I want this field is loaded on the basis of of Employee code column from database.
Here is my code:
ImportConfiguration importConfiguration = ImportConfiguration.builder(SalaryManualEntryLine.class, InputDataFormat.XLSX)
.addSimplePropertyMapping("employeeCode", "Employee code")
.addSimplePropertyMapping("grossAmount", "Gross amount")
.addPropertyMapping(ReferenceMultiFieldPropertyMapping.builder("employeeProfile", ReferenceImportPolicy.IGNORE_IF_MISSING)
.addSimplePropertyMapping("employeeCode", "Employee code")
.build())
.withPreImportPredicate(extractionResult -> {
SalaryManualEntryLine salaryManualEntryLine = (SalaryManualEntryLine) extractionResult.getEntity();
salaryManualEntryLine.setSalaryManualEntry(getEditedEntity());
if (salaryManualEntryLine.getEmployeeCode() == null) {
return false;
} else {
salaryManualEntryLineDc.getMutableItems().add(salaryManualEntryLine);
return true;
}
})
.withTransactionStrategy(ImportTransactionStrategy.TRANSACTION_PER_ENTITY)
.build();
The above code works if I exclude the employeeProfile column but gives exception when validating the employee profile as below:
java.lang.IllegalArgumentException: Lookup properties are not set for property [employeeProfile]
at io.jmix.dataimport.configuration.mapping.ReferenceMultiFieldPropertyMapping$Builder.validate(ReferenceMultiFieldPropertyMapping.java:228)
at io.jmix.dataimport.configuration.mapping.ReferenceMultiFieldPropertyMapping$Builder.build(ReferenceMultiFieldPropertyMapping.java:219)
at com.myapp.hr.view.pr.salarymanualentry.SalaryManualEntryDetailView.onUploadExcelBtnFileUploadSucceeded(SalaryManualEntryDetailView.java:251)