Displaying Updated totals after inline editing

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
ColinP
Posts: 30
Joined: Thu Jul 09, 2020 7:57 am
Location: London UK

Displaying Updated totals after inline editing

Post by ColinP »

There have been other posts about this topic but none seem to fit my predicament exactly.

I have been rightly criticized in previous posts for describing a situation poorly, so people cannot understand the problem. I have taken on board their suggestion that I should submit a .bsv to illustrate the issue and screen shots. I can see their point and will repost my previous issue (which does have an ugly workround for the time being) at some point. My thanks and apologies to those concerned.

In this case I have order lines with quantities for two sizes in a grid showing the line total. I have a dynamic rule to calculate this total and it displays in the grid after the change. (You have to click into another line to get it to update which is rather inelegant, but at least it works)

In the order header I have a grand total quantity for all the lines. To ensure it recalculates when the line total is recalculated I am calling UPDATE OrderHeader and putting a rule in OrderHeader to calculate the new Grand Total. Rather to my surprise I had to get the appropriate Order Header into CONTEXT before the call - otherwise it fails - says it can't find the object OrderHeader. (This implies that the rules execute outside the CONTEXT from which they are invoked, which was a surprise and there does not seems to be a way of passing a parameter to the rule)

The errorlog clearly shows that the total is being correctly recalculated, but it does not refresh in the form.

I attach a very much cut down .bsv and a couple of screen shots including the testlog

thank you for your help. I have spent two days on this problem. At my wits end.
Attachments
Qtotissue.zip
contains bsv and pdf
(201.59 KiB) Downloaded 270 times
Colin
------------------------------------------------------------------------------------------------------------------------
AwareIM 8.7 (Build3012) Windows Virtual Server Derby
ACDC
Posts: 1138
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: Displaying Updated totals after inline editing

Post by ACDC »

I haven't checked your sample, but I recently had a similar problem and queried support as to the refresh problem when editing a line item on an invoice using the standard operations

The solution to your problem I believe is creating a process and adding this process name to your Refresh form settings

Here is my email to support, they replied : "this is a limitation for now"


In a typical Invoice Object with Inv Line Items being owned by Invoice, if I edit one of the Invoiceitems in a POP UP WINDOW using the standard operations with record Edit Object option, one would think there would be an automatic refresh of the parent object form (Invoice) that takes place after the event. Well it doesn’t – I have to create a special process “EDIT InvoiceItem” and then make sure this process is inserted into the Invoice Auto Refresh settings. If I don’t the form does not refresh and presents an error to the user forcing the user to hit the refresh button to enable the invoice to save

If I use the default form setting (as opposed to pop up - form goes to new tab ) this problem goes away because the form is naturally refreshed by the user closing the Invoice Item edit form and arriving back in the parent Invoice form, newly refreshed from this action . (So when not using Default , the feature of built in operation editing becomes dysfunctional in a sense)

If this is not a Bug , does it not make sense to make the parent form automatically refresh when using any form of a pop up edit and built in operation edit, at least make a checkbox on the setup to refresh Parent form automatically if there is a reason why a Auto Refresh should not be there.
Last edited by ACDC on Sun Jan 03, 2021 7:05 am, edited 1 time in total.
ColinP
Posts: 30
Joined: Thu Jul 09, 2020 7:57 am
Location: London UK

Re: Displaying Updated totals after inline editing

Post by ColinP »

Thank you for your response.

My OrderHeader form is called from a query through a 'Operations with Records' it was using a Pop Up form, but changing it to Default made no difference.

The obvious difference between the two cases is that I am using inline editing rather than calling a form to edit the record.

I am not familiar with the Refresh Form Settings. The closest I can find is the Auto-refresh property of the grid, but as understand it this would only refresh the grid containing the OrderLines and not the Order Header. Can you explain a little more please.

What would be the contents of the process called from the Refresh Form Settings which would cause a refresh of the form?

In the real application I have an attribute OrderLine.Active which is a Yes/No field. There is an Operation with Records which calls a process which toggles this attribute between Yes and No. The records are sorted by this flag, so all the inactive records sink to the bottom (and they change colour). If I deactivate or reactivate an OrderLine - the Grand Total does refresh. If I could work out why I might be on the right track.

Thank you for your help - I really appreciate it.

Colin
Colin
------------------------------------------------------------------------------------------------------------------------
AwareIM 8.7 (Build3012) Windows Virtual Server Derby
ACDC
Posts: 1138
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: Displaying Updated totals after inline editing

Post by ACDC »

My OrderHeader form is called from a query through a 'Operations with Records' it was using a Pop Up form, but changing it to Default made no difference.
You need to create a Process that initiates the edit, using the default EDIT operation does not refresh the form (Its a limitation confirmed by support )
Add the process to the Form settings Auto Refresh of the OrderHeader object - When the process is run the Order Header will refresh updating your totals
Attachments
Form Refresh.jpg
Form Refresh.jpg (73.95 KiB) Viewed 6004 times
ColinP
Posts: 30
Joined: Thu Jul 09, 2020 7:57 am
Location: London UK

Re: Displaying Updated totals after inline editing

Post by ColinP »

I tried these changes, but it did not work.

The program flow is

Query on OrderHeaders to view all Orders in a grid.
Operation on Records 'Order Lines' calls process 'EditOrderLines'
This process has one line

'EDIT OrderHeader USING EditOrderHeader'

this displays a form with inline editing for the Order Lines

I have a rule on OrderLines

OrderLine.TotalQuantity=OrderLine.Size1+OrderLine.Size2
FIND OrderHeader WHERE OrderHeader IN OrderLine.OrderHeader
UpdateGtot USING OrderHeader
{it seems necessary to bring the OrderHeader into CONTEXT as pass it to the process - otherwise the testlog is full of errors. The alternative of passing OrderLine and setting OrderLine.OrderHeader.QTotal makes no difference}

The process UpdateGtot is merely

OrderHeader.QTotal=SUM OrderLine.TotalQuantity WHERE (OrderLine IN OrderHeader.OrderLine)

In the form EditOrderHeader I have set the AutoRefresh to Refresh after the process 'UpdateGtot'

I wonder if I have explained what I am trying to do sufficiently. It was when i read that the EDIT had to be from a process and you seemed to imply that it is that process should be in the AutoRefresh property of the form. In the context of what I am try to do, this did not seem logical. I put in the process 'UpdateGtot' as it is after this process that I want the total to refresh. It did not work. Later I put all the processes in, but that was no good either.

If I may try your patience and put my explanation into other words.

I have a number of order lines under an order header. Each order line holds two quantities for two different sizes. I show the total of these two on the line as well as the two quantities. But also I want to show the total for all the order lines in the order header. If the user alters one of the quantities on a line, the total for the line updates. But I can't get the Grand Total in the Order Header to update.


I do appreciate your time on this.

Colin
Colin
------------------------------------------------------------------------------------------------------------------------
AwareIM 8.7 (Build3012) Windows Virtual Server Derby
ACDC
Posts: 1138
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: Displaying Updated totals after inline editing

Post by ACDC »

I played around with your BSV, check the attached re-work and see if you can make sense of it, it seems like a solution
(BTW there could be some debris lying around I should have cleaned up :D )

I changed the object relationship, The OrderLine should be owned by the OrderHeader unless there is a specific need to be peer.
Also changed the process AddOrderLine and renamed your one to AddOrderLineOLD
Attachments
QtotissueNew.zip
(40.6 KiB) Downloaded 278 times
ColinP
Posts: 30
Joined: Thu Jul 09, 2020 7:57 am
Location: London UK

Re: Displaying Updated totals after inline editing

Post by ColinP »

Brilliant - Thank you.

I have my test working, though at this stage I am not sure what the critical feature(s) might be.

I am pretty sure that the two way relationship is critical. Did I miss this on Vlad's video?

Thank you so much for all your effort and time.

Colin
Colin
------------------------------------------------------------------------------------------------------------------------
AwareIM 8.7 (Build3012) Windows Virtual Server Derby
ACDC
Posts: 1138
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: Displaying Updated totals after inline editing

Post by ACDC »

Code: Select all

I am pretty sure that the two way relationship is critical. Did I miss this on Vlad's video?

There is a difference in the way certain AwareIM features work when it comes to the relationship setup and they are not documented

One such example is using "IS DEFINED" on a reference that is owned by the Object in context. It will always return nothing irrespective of its contents

Example, this does not work if OrderLines is owned by OrderHeader :

IF OrderHeader.Orderlines IS DEFINED
Then
REPORT ERROR 'Unable To Delete As Items Exist'

If you change the relationship to peer, it does work -- this is not documented and will take a newcomer many hours to figure out.

The solution here is to use COUNT instead to establish if OrderLines exist
ColinP
Posts: 30
Joined: Thu Jul 09, 2020 7:57 am
Location: London UK

Re: Displaying Updated totals after inline editing

Post by ColinP »

Thanks - I have written to you privately

kind regards

Colin
Colin
------------------------------------------------------------------------------------------------------------------------
AwareIM 8.7 (Build3012) Windows Virtual Server Derby
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Displaying Updated totals after inline editing

Post by tford »

The solution here is to use COUNT instead to establish if OrderLines exist
One other option is to add an OrderLines_Count attribute to OrderHeader and use a rule to keep the new attribute current.
Tom - V8.8 build 3137 - MySql / PostGres
ColinP
Posts: 30
Joined: Thu Jul 09, 2020 7:57 am
Location: London UK

Re: Displaying Updated totals after inline editing

Post by ColinP »

I thought that this issue had been resolved, but when I came to implement the necessary changes to my project I ran into yet another brick wall.

Eventually I found the source of the problem and was able to duplicate it in the attached NEW2.bsv.

To refresh memories, I have and OrderHeader and OrderlIne. Each OrderLine contains a quantity for each of a number of sizes. These fields allow inline editing.

I show the total for each line using a rule in OrderLine

OrderLine.TotalQuantity=OrderLine.Size1+OrderLine.Size2

and I show a total for all lines using a rule in OrderHeader

OrderHeader.QTotal=SUM OrderLine.TotalQuantity WHERE (OrderLine IN OrderHeader.OrderLine)

When a single quantity is changed nothing happens until the user passes the focus to another attribute - at which point the line total is updated but not the grand total. When the user changes the focus to another cell then and only then is the Grand Total Updated.

This behavior only occurs when the line total, OrderLine.TotalQuantity, is shown on the form. If the line total is not shown on the form it works fine and the grand total is immediately updated.

Looking at the Testlog is most instructive.

In the first extract timed at 17:21:13 the user had changed one quantity and changed the focus to another attribute. You can see that the process has invoked the update of the grand total and reached the right figure - but has not displayed it on the form

The second extract timed at 17:24:51 the user has changed the focus to yet another attribute which has invoked the update of the grand total and displayed it on the form.

The exact wording deeply significant. If the process finds no change in the value of the attribute it USUALLY says something on the lines that "it was not updated because the value was the same."

I am driven to the conclusion that the process is working on two different copies of the OrderHeader in different CONTEXTS - but how can this be?

More importantly - what is the solution?

My thanks in advance for any help on this
Attachments
NEW2.zip
(40.75 KiB) Downloaded 239 times
Testlog2.png
Testlog2.png (77.02 KiB) Viewed 5637 times
Testlog1.png
Testlog1.png (151.66 KiB) Viewed 5637 times
Colin
------------------------------------------------------------------------------------------------------------------------
AwareIM 8.7 (Build3012) Windows Virtual Server Derby
Post Reply