How can I log all records from a grid app into Audit_log table?

Good Day,
I face a big issue, That i have many grid application with buttons to insert, update ,update, delete many records one time, and i want to store the changed records to Audit_log table for log.
But unfortunately, when I excute log module it store only access grid applications

Is there a way to solve this issue, Or store changed records to Audit_log table for log?

Afaik, there is a setting at the audit trail to define what you want to log. But if these are plain grids with custom buttons and code, this is not applied. In the onbeforeinsert, delete etc. you can invoke the logging manually by sc_log_add

1 Like

I really appreciate your support in this endeavor.
But how can I do that, Can you please get me an example for this issue, and where i can do that?
Thanks in advance

If you have a run button then you have an onrecord event. To add a record to the log file you can use the sc_log_add function (see documentation) Something like

$myvars= build your text here
sc_log_add($myvars).

This is the manual way of adding records to the log.

1 Like

That was very kind of you. How can I ever repay you?

When I choose one record like this picture


and execute code like this picture

it store all records not I checked like this picture

So, How I store only record that I selected before?

Another question please

How can I store any transaction(add, update, delete, …etc) made by button and insert it into Audit_Log table as shown in above picture

How can store any transaction happened in a grid application like this

The onrecord event fires on each and every record. so you must intercept the onprocesrecord event when you click the run button.

the second question: I’m not sure, but afaik you get both records in the onprocesrecord so you need to form your message and proces it like my previous mail.