This topic is locked

Logging an Export

5/5/2025 7:24:07 AM
PHPRunner General questions
D
druck281 author

When exporting records using the built-in Export page, can I capture a list of the IDs of the exported records to be used in a log entry?

I have an audit table and my own custom log function. My goal is to log when a user processes an export of records but I do not want to log each individual exported record. The resulting log entry should contain a JSON field with

Exported IDs: [comma-separated list of IDs]
Count: [count of exported records]

I have been messing with BeforeRecordExported but it appears that runs once for each record and it is not really intended for this purpose. I have tried using AI but it keeps telling me to add things to multiple evets that don't exist like 'BeforeProcessExport'. If someone can point me in the direction to capture a list of IDs, I think I can handle the rest.

Thanks!

Sergey Kornilov admin 5/5/2025

BeforeProcessExport event certainly does exist.

img alt

You can use this event to see what is being passed via POST and use that information to get a list of IDs and save it in the database.

D
druck281 author 5/5/2025

Derp...you are totally correct. My apologies. I was looking at that as a Before Process page that would fire before the export page was displayed so I looked right past it. After paying a little closer attention, the Export page does not actually display but simply triggers the download. Does that event collect an array of the records to be included in the export?