Can you update a factbox from a subform?

zaq1028zaq1028 Member Posts: 19
I added code that calculates the Inventory on Hand at a certain location to the Sales Line Factbox. It works as expected, but I would like the factbox to update once the user enters the Item No. in the Sales Order Subform. It currently only updates once the line is selected. How can I update the factbox from the subform's OnValidate trigger?

Best Answer

  • JDVyskaJDVyska Member Posts: 179
    Answer ✓
    Ohhh, gotcha. That's the DelayedInsert: Yes on the Sales Order Subform. Entering the "no.", the row technically still doesn't exist.

    If you test carefully, you could try, on SO Subform (46), tossing a "CurrPage.SAVERECORD" in the OnValidate of No. Then the OnAfterGetRecord is called as soon as you enter a "No.".
    JEREMY VYSKA
    CEO, Spare Brained Ideas, Göteborg, Sweden
    New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"

Answers

  • JDVyskaJDVyska Member Posts: 179
    Subform suggests classic. What version are you developing for? (In general, it's rather difficult in Classic, but not impossible, to update form related information on Subform changes.)

    It's also why, in many versions of NAV Classic, the Sales Line FactBox (Item Information) is just a set of fields on the Subform itself, which already does get updated after the user selects an Item No.
    JEREMY VYSKA
    CEO, Spare Brained Ideas, Göteborg, Sweden
    New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"
  • peikbapeikba Member Posts: 1
    If you are programming in pages and for the RTC client, you can use the ProviderID property to determine which control should link with the FactBox. In the Classic it is a bit more complicated.
  • zaq1028zaq1028 Member Posts: 19
    I am working in NAV 2015 with the RTC client. How do I use the ProviderID property to determine the FactBox?

    Thank you for your help!
  • JDVyskaJDVyska Member Posts: 179
    Ah, well, 2015 is a world of easier.

    First, general info: The Sales Line Factbox is already linked on the base Sales Order with the ProviderID. If you design the Sales Order, and scroll way down to the FactBox Area, look at the properties of the Sales Line FactBox. It has "ProviderID" of 58 set. If you now go look at the properties of the Sales Line part (the subform), you'll see it has an ID of 58. Once you set a Provider ID on a FactBox, you can then use the SubPageLink to connect the two.

    Now, for your situation. You've added a field to display some calculated values (in this case, Inventory for a specific location). A lot depends on where you're putting that code. I would say that you're on the right track if you have the code living on Page 9087 (Sales Line FactBox). All you should need to do now is add a call to your code in the OnAfterGetRecord() trigger on Page 9087. Any time the user changes the Sales Line, that code will get run.
    JEREMY VYSKA
    CEO, Spare Brained Ideas, Göteborg, Sweden
    New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"
  • zaq1028zaq1028 Member Posts: 19
    That is what I currently have. The issue is, that the FactBox only updates once the line is complete. Ideally, I would like the FactBox to be updated once a user selects an Item No., without them having to enter a quantity, or having them move to another line and then return back to it. Does that make sense?
  • JDVyskaJDVyska Member Posts: 179
    Answer ✓
    Ohhh, gotcha. That's the DelayedInsert: Yes on the Sales Order Subform. Entering the "no.", the row technically still doesn't exist.

    If you test carefully, you could try, on SO Subform (46), tossing a "CurrPage.SAVERECORD" in the OnValidate of No. Then the OnAfterGetRecord is called as soon as you enter a "No.".
    JEREMY VYSKA
    CEO, Spare Brained Ideas, Göteborg, Sweden
    New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"
  • joshuasungjoshuasung Member Posts: 37
    I think I know what you mean.
    Try "Item Invoicing Factbox" as template instead.
    It populate item information right after you enter item no.
    Joshua H Sung

    Sr. Project Manager
    S-Metric, LLC
    jsung@smetric.com
Sign In or Register to comment.