Hi everyone. I have written a module called Claims that has fields that depends upon other modules. Things like Contracts and Third Parties. I am trying to setup the import/export features for this module.
Let’s say I have a CSV file of Claims, and some of the Third Parties for the Claims do not exist in the system yet. Is there a way to specify in the import information to auto insert the new Third Parties if they do not exist? Or is it a requirement that you have to import all your Third Parties prior to importing Claims?
Thanks
Alter your module code as follow:
- Create an upload from the CSV file (DO NOT use the Tools>import for your module)
- Read the file using the PHPSpreadsheet library (included in Dolibarr)
- Check if the third party exists and if not create it
- Import the Claims or do whatever you need to do
I guess, in your modules database table you have a field named fk_soc
to link the record to a third party so … yes, they should be present before importing your claims, no matter how you do it.
Thanks for the reply. I will keep your suggestion in my back pocket, but for now, I have chosen to force my customers to import 3rd parties, contracts, products, and so on before importing Claims. It’s not ideal, but I’d rather do that, than have a different importer.