Identifying the pre-edited value of an edited input of an editable table
Application Type
Traditional Web
Service Studio Version
11.11.5 (Build 44224)

In an inventory application it is necessary to track a product's balance on hand.  When selling a product the balance on hand reduces.  When a user changes the quantity of the product sold (using an editable table), I need to add the old value back and deduct the new value from the balance on hand. I have not found a way to identify the old value after the new value has been entered by the user.

mvp_badge
MVP
Solution

Hi Leon,


You can include another field on the structure that you bind to the Editable Table widget, so you would end up with one attribute Quantity_Original and Quantity_New which you would populate at first with the same value.

Then on your Editable table, you only show one field binded to the Quantity_New field. When creating you write the value on both Quantity_New and Quantity_Original and when updating you only update the Quantity_Original.


In this way, in the end, you would have both the old and the new value.


Kind Regards,
João

Hi Leon,

If possible for you, could you please share your OML?

Thanks & Kind Regards,

Sachin

Sachin,

My application is very large and you will have difficulty navigating your way around it without lengthy explanations.

The example I have given in my questions is a generic one because this element of an inventory system is understandable to all.  My application is different but the principle is the same.

I have a medical system where therapists are charging according to "codes".  The quantity of codes are limited by the medical aid companies.  So I hold the "BalanceToBill" on the entity.  The user can do one of three things in an editable table:

1. Add a new record  (the system deducts the quantity billed from the "BalanceToBill")  

2. Update a record (the system should add back the "old" quantity  and deduct the "new" quantity billed, from the "BalanceToBill")  

3. Delete a record (the system adds back the quantity billed to the "BalanceToBill")  

I am having the problem with number 2.  I cannot access the "old" quantity.

I hope you can assist with this explanation.

Thanks

Leon

Ok. So, where do you hold the old quantity? In the same entity where you are storing "BalanceToBill"? It would be great if you can share the screenshot of your editable table and entity to which you have bind the table.

mvp_badge
MVP
Solution

Hi Leon,


You can include another field on the structure that you bind to the Editable Table widget, so you would end up with one attribute Quantity_Original and Quantity_New which you would populate at first with the same value.

Then on your Editable table, you only show one field binded to the Quantity_New field. When creating you write the value on both Quantity_New and Quantity_Original and when updating you only update the Quantity_Original.


In this way, in the end, you would have both the old and the new value.


Kind Regards,
João

João,

I was hoping that it would not be necessary to add fields and use up database space unnecessarily. In my application there are 3 fields that affect BalToBill. So, I would need to add 3 additional fields.

In the past I used software where one could access the pre-edited value and the post-edited value in an on-change procedure.  I was hoping that I could find a way to do this with OutSystems. If not, I will have to add the fields.

Thank you for your help and best regards,

Leon

Hi Leon, 

i think you are confusing us with your original post.  You are talking about an editable table, that is a UI widget, so it sounds a bit like you want to see in you UI the effect of your change and for that need to hold on to both original and new value.

So that´ s what José is proposing, he´ s not saying you need to have extra columns in your database.

Completely separate from your UI, you will probably want to have a robust update server action that makes sure your inventory amount is properly changed.  

For that you can of course first read (with an aggregate or maybe a GetForUpdate)  the Sale record.  That will give you the old value.  Then you can calculate an InventoryDeltaAmount as the new SaleAmount (coming as input from your screen into your update action) minus the old value (you just read from the database).  After that you update the sale record (at which point you loose the old value) 

Now you update the inventory record by substracting the calculated delta from inventory amount.  If new sale amount is less than old sale amount, this will be a negative you substract, so augmenting the inventory.  

Dorine

Thank you Dorine.  I did miss the point in João's explanation.  I will try to implement it as you have explained.

Regards,

Leon

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