Use the After Row Hook
The After Row scripting area lets you execute custom PHP code immediately after each record from the import file has been saved to the database. This is useful for setting calculated fields or updating in-memory collections that were built during the Before Run phase.
When to Use After Row
Use the After Row area when you need to:
- Set fields that do not have a corresponding column in the import file because they are calculated from other fields' values.
- Update arrays or collections that were initialized in the Before Run area, so that uniqueness checks remain accurate for subsequent rows.
For example, after inserting a new device, you should add the new record to the $deviceArray created in the Before Run area. This ensures that if a later row in the same import file references the same device code, the Before Row hook will find it and update instead of creating a duplicate.
Always keep your in-memory arrays in sync with new inserts. After an insert, add the new record to the original data collection or array created when the import started.