FlowField not updating immediately in Purchase Header

I am trying to calculate the sum of the "Purchase Line Total Weight" from the Purchase Line table and display it in the Purchase Header using a FlowField. However, the FlowField only updates when I insert a new line or when I close and reopen the page.

What I want to achieve is for the Purchase Header field to update immediately whenever a new line is inserted, an existing line is modified, or a line is deleted in the Purchase Line.

Could someone help me understand why the FlowField isn't updating as expected and suggest the best approach to make sure the field in the Purchase Header updates in real-time?
0omorheq73bt.png

Answers

  • lubostlubost Member Posts: 628
    You have to update header page to get update all header flowfields. You have a possibilities:
    - if you want to show total to user, you have to apply time based script (https://www.packtpub.com/application-development/mastering-microsoft-dynamics-365-business-central)
    - if you need total for internal calculation, you can define header record and use a calcfields method.
  • mustafaAlsoufimustafaAlsoufi Member Posts: 65
    @lubost I would like to display the total of the "Purchase Line Total Weight" in the Purchase Header, but I believe the link you shared doesn't work. Could you please provide the code here so I can implement it?

    Also, where exactly should I add the code? I believe the code should be added to the Purchase Order Subform (the page where the lines are updated), since that's where the Purchase Line data gets updated. Would you agree with that approach?
  • Developer101Developer101 Member Posts: 561
    Hello You can have a FlowField on Purchase Header calculating Total Weight, that is fine.
    But do you have to display it on Purchase Invoice page? Why not display it with the rest of the document totals?
    United Kingdom
  • mustafaAlsoufimustafaAlsoufi Member Posts: 65
    @Developer101 to clarify, I only want the total to be updated in the Purchase Header, not in the Purchase Line document totals. Is there a way to achieve this? I’m wondering if there’s a function or event that can trigger an immediate update to the Purchase Order page as soon as the Purchase Line fields are populated or modified. Would that be possible?
  • lubostlubost Member Posts: 628
    - Purchase header page don't know that lines are changed.
    - Purchase lines page don't know anything about purchase header page
    You have following approaches:
    - Refresh purchase header page every x seconds to update total fields. You can do it by using javascript addin in header page.
    - Purchase line page has a "card like" part with some totals. You can add your total field to this part.
  • Developer101Developer101 Member Posts: 561
    Lubost’s reply is valid.

    Flowfield on the purchase header table will be updated no problem. You don’t have to do anything in addition. So if you want to use it on a report or anything you could.

    But your issue is that you want to update it on the purchase invoice page (header page) real time, isnt it. You said you want it to be updated immediately in your post. My question was why do you want it? What is the reason? Is this a requirement from customer?

    If this real time update is for user to see when they add/modifying/ deleting then easier will as suggested by me and lupost is to add it in the document totals (card like part on the subpage!
    United Kingdom
Sign In or Register to comment.