Hi Good People...
I'm creating an application, which Calculates all expenses. It shows TOTAL, DATE, and Created BY...it also has an option to clear/delete the calculated records...
Now my question is, which logic should I implement in order for it to save deleted records in another screen (bin or history) so that the user will be able to retrieve deleted records in the future.
thank you in advance
Hi Tafadzwa,
If you don't want to completely remove the record, you can add IsDeleted attribute to your entity.
Default value is False, when delete set it to True.
Regards,
Khuong
Hello Tafadzwa,
If I understand your question well then I would like to suggest you that,
You need to perform soft delete.
Please check below post for your reference.
https://www.outsystems.com/forums/discussion/75330/soft-delete/
Hope it helps you.
Ajit Kurane.
If you still want access to 'deleted' records, there are 2 options:
The easiest is to have a boolean attribute IsDeleted in your entity. This might do the trick but if you have a lot of records it might not be the best solution.
The other option is to have another entity where you can move the deleted records to after deletion.
HI tafadzwa ignatious
save deleted records in another screen >> Regarding this Logic you should add one more column in same entity (Status) and while deleting the records don't use the delete the server action, use update server action (update the status is false) in listing screen you can add the condition status - true. Then u will get the deleted records.
Hi Tafadzwa,I would go with Stefano's solution.His first part talks about the soft delete others are also mentioning. But like he says if it is a lot of records is better to follow his second solution where you move your records to a "history" table.So for performance go with Stefano's solution
Hello! As I said before you have a lot of good answers here, and as I saw that you didn't understand how to develop, first I advise you to look first at the training and then learn and go to things more difficult and with more logic. Without a foundation, your logic will not grow so much or it will grow slowly.
Anyway, I did an example.
1- You need to put this attribute, isDeleted
2- to list all the expenses that are not temporarily deleted your filter the list using the isDeleted attribute that we inserted in the expenses' entity
3- To list all expenses that are on the bin you filter again using the isDeleted attribute but in this case, you want the records that were "deleted"
To change the attribute I will use a server action that I created to update that record on the database where I will put the isDeleted attribute is true
I have done an example and you can play a little if you want. I will give you my OML. Let me know if it helped you :)
You have the screen of expenses and expenses in, the bin is where are all the records that were deleted but are still in the database. You have two options on the expenses screen, to delete the record temporarily, or to delete it permanently.
https://marcio-carvalho4.outsystemscloud.com/SoftDelete/Expenses
For this first option, I think you can do it. But I recommend going in the future(or even now) with @Stefano Valente answer :)
Márcio