We have a master table in which we are creating a record and it is getting stored in the same table .
if we update the particular data the updated data will get saved in the table but we want the past data of that record to get saved in different table ( History Table).
Hi,
In the OnAfterFetch, store the current data in local variable.
and when the data gets updated. compare it with local variable. If the value differs, Create a record in history table.
This is one of the way to achieve your requirement.
Regards,Wasimkhan S
this is logic that should typically go into either a CRUD wrapper, or a server side business logic, not on client side.
Like this?
yes,
that is already better (at least you have transactionality and you only go to server once)
but I would say:
Dorine
Hi @Wasim Khan, I am a beginner in Outsystems and I tried implementing your logic into my app however it's not saving anything in my history table. Do you have an OML which I could refer to? Thank you very much.
Hi @Katie Midge ,
I dont have OML for this. Pls check you have assigned the values correctly.
Hello Prachiti,
Here's a suggestion for storing past data: Before updating new data, check if the data already exists using its ID. If it does, create or update a History table with that data, and then update the data in the existing table.
I hope this explanation helps you understand the process better.
Let me know if you have any further questions.Thanks
Hi @PRACHITI THOMBARE, There are two ways: first, when you are creating or updating anything in the main table, make an entry in the history table right after that. For this, you can call the insert wrapper of history in the main table's crud wrapper. In this case, the values of the last entry in the history table will be the same as the main table values. For the second method, in the insert wrapper of the history table, fetch the latest record of the main table and insert it in the history table, then in the main table's update wrapper, first call the insert wrapper of the history table, then make the entry in the main table.
ThanksGitansh Anand
Hi @PRACHITI THOMBARE,
Do you want to add record in history table only once or whenever you update any record changes will capture in history table and updated one is remain in main table?
Thanks
Ridhima
yes correct.
Yes.. Every time when we update the data ,the updated data will get save in the main table but the past record should get saved in the history table .
Hello @Wasim Khan
What is Check form data?
The data which was captured in OnAfterFetch.
the data that is getting saved in history table is the updated one , we want to save Past data.
Thankyou ...
Resolved .
Good to hear. Thanks. You can mark the solution if your issue resolved.
Regards,
Wasimkhan S