15
Views
2
Comments
Solved
How to create a record?
Application Type
Traditional Web

Hey! 

So, I am doing an app to keep on track my tasks and my "to do list" and I want to create something to record the updates that I have done (changed description, changed task state, ect). I have everything ready, the tasks already have the all the info and I have a server action to update the tasks. Now, I only need to record the change. Do I need to create a new Entity to save the changes? Because, when I update the task, I update the SQL, I don´t create a new Item

Please help :)

Tnx 

Rank: #55
Solution

Hi Gonçalo,


The logging of changes are adapted to your needs.

The simplest way is to include CreatedBy, CreatedOn, UpdatedBy, UpdatedOn fields on the entity to record when it was created and by whom and by when it was last updated and by whom.


This of course is not enough for other scenarios were more logging is needed.

In the scenario, you want to keep a copy of the task along time, indeed you would need to create another table, for instance Table_History with the fields from Table, including Table Id, who changed it and when.

With this table, you would have a record of task details along time and when were they changes made.

If that is the case, you better create a wrapper CreateOrUpdateTask that creates or updates the Task record and always creates the respective record in Table_History, so your UI does not have to deal with this logging complexity and to always create the respective history change record.  


Hope it helps.


Regards,
João

Rank: #299

Hi Goncalo,

You don't need to create a new entity to store the updated values. Just use the Update entity action to update the existing records. But please make sure you are passing a unique identifier to Update entity action, when you update any record to make sure you are updating single record else all the record of your entity will get updated with same values. Also, refer this post which was posted by you for not to update all the records I guess. :)

https://www.outsystems.com/forums/discussion/67263/my-database-is-changing-all-data-instead-of-only-one/

Thanks & Kind Regards,

Sachin


Rank: #55
Solution

Hi Gonçalo,


The logging of changes are adapted to your needs.

The simplest way is to include CreatedBy, CreatedOn, UpdatedBy, UpdatedOn fields on the entity to record when it was created and by whom and by when it was last updated and by whom.


This of course is not enough for other scenarios were more logging is needed.

In the scenario, you want to keep a copy of the task along time, indeed you would need to create another table, for instance Table_History with the fields from Table, including Table Id, who changed it and when.

With this table, you would have a record of task details along time and when were they changes made.

If that is the case, you better create a wrapper CreateOrUpdateTask that creates or updates the Task record and always creates the respective record in Table_History, so your UI does not have to deal with this logging complexity and to always create the respective history change record.  


Hope it helps.


Regards,
João