Use ImportAction to import records and related records

I am using ImportAction to import a list of registrants and addresses. Each registrant can have a physical address and mailing address. The csv file looks something like: firstname,lastname,phys_address,phys_city,phys_state,mail_address_mail_city,mail_state,yob. My tables look like: firstname,lastname,phys_address_id,mail_address_id,yob The documentation shows how to use relationships for lookups of existing relationships but I'm not certain how to create new ones. During the import process, I would like to create new addresses if the registrant does not exist, or update the addresses if the registrant does exist. I know I can do this without using ImportAction but I like the ability to map columns during the import process. Thanks!
1 Reply
justjigga
justjiggaOP5mo ago
I discovered several methods that should help but they don't seem to work.
Does anyone have any additional details on beforeValidate , beforeFill , beforeSave , and beforeCreate? I tried all 4 methods and can't seem to delete the additional columns from the import before the data is saved. I would like to delete all of the address fields since I'm storing that information in another table. When I try unset($this->data['phys_address']); I still get an error about the phys_address field during the insert.
Want results from more Discord servers?
Add your server