Skip to main content

Notifications

Small and medium business | Business Central, N...
Unanswered

How can I divide one field with another and display it in third field?

Posted on by 221
Hello!
 
I am working with a bakery at the moment, and I have a little case.
I have added two fields to the /Production Order/ table:
- /Total weight/ - sums all weights of component values on the specific Production Order
- /Dough weight/ - gets the weight of one dough specified in the Item-card
 
I want to add a third field named /Number of doughs/ that displays the number of doughs the bakery can make based on those two values.
Therefore, I want to divide the Total Weight with Dough Weight to get an estimate of how many doughs are going to be made.
 
This is the code I am working with:
 
fields
    {
        field(50100; /Number of doughs/; Integer)
        {
            // HOW CAN I DIVIDE TOTAL WEIGHT WITH DOUGH WEIGHT AND DISPLAY THE VALUE HERE?
        }
        field(50101; /Total weight/; Decimal)
        {
            FieldClass = FlowField;
            CalcFormula = sum(/Prod. Order Component/./Expected Quantity/ where(/Prod. Order No./ = field(/No./), /Routing Link Code/ = const('BAKE')));
        }
        field(50102; /Dough weight/; Decimal)
        {
            FieldClass = FlowField;
            CalcFormula = lookup(Item./Dough weight/ where(/No./ = field(/Source No./)));
        }
    }
 
Additionally, I would like to round that number up to the nearest whole number, because they always want to make a little too much than too little dough.
 
How can I achieve what I am looking for?
Categories:
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,472 Super User 2024 Season 2 on at
    How can I divide one field with another and display it in third field?
    Hi, first of all, Flowfield does not have a Validate trigger or OnModify. And flowField cannot reference another Flowfield.
    More details:
    Dynamics 365 Business Central: A flow field is part of the query column list, this is not supported (Flowfield based on Flowfield)
     
    So you need to determine when you calculate the "Number of doughs", the simplest way is to add an action to calculate the current value. Because no matter you calculate it in the OnInsert or OnModify trigger of the Production Order table, the final value may not be the latest. Or you change "Total weight" and "Dough weight" to non-flowfield field, update these two values when Prod. Order Component and Item are updated.
     
    PS: How to get value from a FlowField field
     
    Hope this can give you some hints.
     
    Thanks.
    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans