audit trail

Hello everyone


I have a table, and every time I update one of it's fields, I want an audit trail old & new record with action type (Create, update, Delete).


I want to make an own logic/ own Lib ( without using forge components)


Thank you!

Hi Diaa,

you can use this table as example for an audit trail. Just add/remove fields according to your needs, but this one have the basic fields to keep a decent track of changes.

Entity is to save the entity name

RecordId is the Id of the record changed

PreJSON is the JSON of the record before the changes

PostJSON is the JSON of the record after the changes

CreatedBy is the user who performed the change

CreatedOn is the datetime that happened


Kind Regards


Hello José 

Thank you so much, but I have a question, what if I need to know the Action type (update, new or delete)?
what should I do?

Diaa

Add another field to save the action type too.

Thank you so much @José Gonçalves 
But I have another question please, how can I save old & new value in the entity?

Are you sure you will only update a single value on each update? Or could be a list of values to change?

That's why my model uses JSON to save the old record and the new record.

You can create a screen to manage those changes by deserializing both JSONs and compare values from old to new record.

I need a Audit for any table I create, contain an original & modified values
So, your example entity perfect

Hi @Diaa JMohammad ,

Step 1: Create a new Audit Entity with the required attributes (EntityName, Column, PreviousValue, CurrentValue, CreatedBy, CreatedOn).

Step 2: Create an Audit action to create a new entry in the Audit Entity. Add input parameters to the action with the name of the above-mentioned 6 attributes.

Step 3: Call the Audit action to create or update the entity wrapper for the different entities and pass the input parameters to make audit entry into the Audit entity.

Cheers

Thanks, Aadhavan S


Hi Aadhavan 

Thank you so much, but I have a question, what if I need to know the Action type (update, new or delete)?
what should I do?

Diaa

Most Welcome Diaa. You can add one more attribute to the audit entity to store the type of action and pass one more input text parameter to the Audit action with the text data type. You can use static entity for this column also

Thanks, Aadhavan S

Really appreciate your help Aadhavan ,
another question, can you explain point #2 in more details?

Really appreciate your help @Aadhavan Shanmugam

But I have another question please, how can I save old & new value in the entity? 

Thanks @Diaa JMohammadBefore performing create or update action for your entity, get the previous value in the local variable. now you will have old value and input is a new value. pass both into Audit Entity Create or Update action.


Thank you so much @Aadhavan Shanmugam , really thank you & if I need any help I will back to you 😅

Hi Diaa,

you can use this table as example for an audit trail. Just add/remove fields according to your needs, but this one have the basic fields to keep a decent track of changes.

Entity is to save the entity name

RecordId is the Id of the record changed

PreJSON is the JSON of the record before the changes

PostJSON is the JSON of the record after the changes

CreatedBy is the user who performed the change

CreatedOn is the datetime that happened


Kind Regards


Hello José 

Thank you so much, but I have a question, what if I need to know the Action type (update, new or delete)?
what should I do?

Diaa

Add another field to save the action type too.

Thank you so much @José Gonçalves 
But I have another question please, how can I save old & new value in the entity?

Are you sure you will only update a single value on each update? Or could be a list of values to change?

That's why my model uses JSON to save the old record and the new record.

You can create a screen to manage those changes by deserializing both JSONs and compare values from old to new record.

I need a Audit for any table I create, contain an original & modified values
So, your example entity perfect

Hi @Diaa JMohammad ,

Step 1: Create a new Audit Entity with the required attributes (EntityName, Column, PreviousValue, CurrentValue, CreatedBy, CreatedOn).

Step 2: Create an Audit action to create a new entry in the Audit Entity. Add input parameters to the action with the name of the above-mentioned 6 attributes.

Step 3: Call the Audit action to create or update the entity wrapper for the different entities and pass the input parameters to make audit entry into the Audit entity.

Cheers

Thanks, Aadhavan S


Hi Aadhavan 

Thank you so much, but I have a question, what if I need to know the Action type (update, new or delete)?
what should I do?

Diaa

Most Welcome Diaa. You can add one more attribute to the audit entity to store the type of action and pass one more input text parameter to the Audit action with the text data type. You can use static entity for this column also

Thanks, Aadhavan S

Really appreciate your help Aadhavan ,
another question, can you explain point #2 in more details?

Really appreciate your help @Aadhavan Shanmugam

But I have another question please, how can I save old & new value in the entity? 

Thanks @Diaa JMohammadBefore performing create or update action for your entity, get the previous value in the local variable. now you will have old value and input is a new value. pass both into Audit Entity Create or Update action.


Thank you so much @Aadhavan Shanmugam , really thank you & if I need any help I will back to you 😅

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.