web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

procedure to switch a field options in a factbox

(0) ShareShare
ReportReport
Posted on by 373

Hi Community,

I am trying to connect line type in planning job to show fields in a factbox, but when I change the status budget for billable is not matching.

Could you help me with this issue?

I will appreciate, 

Thank you

pastedimage1676640306546v3.png

This is the code that I write:

pastedimage1676640935659v4.png

trigger OnAfterGetCurrRecord() // after get a record sum totals
    begin
        if rec."Line Type" = Rec."Line Type"::Budget then begin
            Rec.CalcSums("Total Cost");
            Rec.CalcSums("Line Amount");
            Rec.CalcSums("Net Margin");
            //Rec.CalcSums("Invoiced Amount (LCY)");
            TotalCostPlanningLine := Rec."Total Cost";
            TotalBudgetLineAmount := Rec."Line Amount";
            TotalNetMargin := Rec."Net Margin";

        end;
    end;

    var //Globals variables
        TotalBudgetLineAmount: Decimal;
        TotalCostPlanningLine: Decimal;
        TotalNetMargin: Decimal;
I have the same question (0)
  • Muaaz Deyab Profile Picture
    39 on at

    Can you explain more about what you want to do?

  • Manuel Lozada Profile Picture
    373 on at

    Hi Muaaz,

    I try every time that I change or switch the status in a line (Budget, billable, and Both budget and billable) change the totals in my factbox.

    Thank You

  • Muaaz Deyab Profile Picture
    39 on at

    I think you should call this

    if rec."Line Type" = Rec."Line Type"::Budget then begin

               Rec.CalcSums("Total Cost");

               Rec.CalcSums("Line Amount");

               Rec.CalcSums("Net Margin");

               //Rec.CalcSums("Invoiced Amount (LCY)");

               TotalCostPlanningLine := Rec."Total Cost";

               TotalBudgetLineAmount := Rec."Line Amount";

               TotalNetMargin := Rec."Net Margin";

    onValidate of the Line type

  • Manuel Lozada Profile Picture
    373 on at

    Hi Muaaz,

    I did, but still not working.

    Thank you

  • Muaaz Deyab Profile Picture
    39 on at

    Can you show me how did you wrote it?

  • Manuel Lozada Profile Picture
    373 on at

    Hi Muaaz

    something like this

    thank for help me, I am beginner AL.

    field("Total Cost"; TotalCostPlanningLine)

               {

                   ApplicationArea = Basic, Suite;

                   Caption = 'Total Budget Cost';

                   ToolTip = 'Show total Budget Cost for current job planning lines.';

                   Visible = true;

                   Editable = false;

               }

               field("Line Amount"; TotalBudgetLineAmount)

               {

                   ApplicationArea = Basic, Suite;

                   Caption = 'Total Budget Billable';

                   ToolTip = 'Show total amount for current job planning lines.';

                   Visible = true;

                   Editable = false;

               }

               field("Net Margin"; TotalNetMargin)

               {

                   ApplicationArea = Basic, Suite;

                   Caption = 'Total Net Margin';

                   ToolTip = 'Show Net Margin for current job planning lines.';

                   Visible = true;

                   Editable = false;

                   AutoFormatType = 10;

                   AutoFormatExpression = '<precision, 2:2><standard format,0>%';

               }

               field(LineBillableAmount; TotalBillableLineAmount)

               {

                   ApplicationArea = Basic, Suite;

                   Caption = 'Total Real Billable Amount';

                   ToolTip = 'Show total amount for current job planning lines.';

                   Visible = true;

                   Editable = false;

               }

    field("Line Type";Rec."Line Type")

               {

                   ApplicationArea = Basic, Suite;

                   Visible = true;

                   Editable = false;

                   trigger OnValidate() // after get a record sum totals

              begin

              if rec."Line Type" = Rec."Line Type"::Budget then begin

               Rec.CalcSums("Total Cost");

               Rec.CalcSums("Line Amount");

               Rec.CalcSums("Net Margin");

               //Rec.CalcSums("Invoiced Amount (LCY)");

               TotalCostPlanningLine := Rec."Total Cost";

               TotalBudgetLineAmount := Rec."Line Amount";

               TotalNetMargin := Rec."Net Margin";

           end;

       end;

               }

           }

       }

       trigger OnInit() //initialize the page equal 0

       begin

           TotalBudgetLineAmount := 0;

           TotalBillableLineAmount := 0;

           TotalNetMargin := 0;

           TotalCostPlanningLine := 0;

       end;

       trigger OnAfterGetCurrRecord() // after get a record sum totals

       begin

           if rec."Line Type" = Rec."Line Type"::Budget then begin

               Rec.CalcSums("Total Cost");

               Rec.CalcSums("Line Amount");

               Rec.CalcSums("Net Margin");

               //Rec.CalcSums("Invoiced Amount (LCY)");

               TotalCostPlanningLine := Rec."Total Cost";

               TotalBudgetLineAmount := Rec."Line Amount";

               TotalNetMargin := Rec."Net Margin";

           end;

       end;

       var //Globals variables

           TotalBudgetLineAmount: Decimal;

           TotalBillableLineAmount: Decimal;

           //TotalUnitPrice: Decimal;

           TotalCostPlanningLine: Decimal;

           TotalNetMargin: Decimal;

  • Muaaz Deyab Profile Picture
    39 on at

    Maybe remove the condition so it would show the sum for each line

  • Suggested answer
    IB-29041624-0 Profile Picture
    1,187 Moderator on at

    Why not do a calcfields in the OnAfterGetRecord trigger regardless of the status?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,086 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,290 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,218

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans