Lookup field refresh Flowfield

Hi everyone, i have a question about refreshing a Flowfield in the header based on LookUp Flowfield in the line part. 

Things may be a little be tricky here. 

I've created a document page. Header has a Flowfield that sum each line amount, each line amount is calculated according to Quantity * Sales price, the Sales price is a Flowfield that looks up the Unit Price in the corresponding Sales Order. 

What i want to do is: When i change the Unit Price in corresponding Sales Order, the Flowfield in my document header can automatically refresh, showing new total line amount.

What i am doing right now is: 

-In my Document page, the line part set UpdatePropagation = Both & set up the Flowfield to sum line amount;

-In my Line Page, put the following code under OnAfterGetRecord trigger:

rec.Validate(Quantity);
 
-In the Quantity field, put the following code under OnValidate Trigger:
Line Amount := Quantity * Sales Price.
-In the Sales Price field, set it up as a Flowfield to lookup Unit Price from Sales Order. 
What i got so far: After i change the unit price in the Sales Order, the Sales Price and Line Amount in the line page is refreshed automatically. But the Total Line Amount in the header is showing a 0 forever.
Could anyone share some ideas how to make this work. Thank you in advance! 
Related
Recommended