MATRIX Form update issue

RoddyMcLeanRoddyMcLean Member Posts: 101
I'm having an issue with Matrix form updates. This is a custom one based on Account Schedules. Everything starts of fine in the following view VIEW1.BMP: -


I select another Account Schedule (called view in my system) VIEW2.BMP: -


After pressing the right cursor button several time the view returns to normal VIEW3.BMP: -


Any help would be greatly appreciated.

Regards
Roddy

Comments

  • SogSog Member Posts: 1,023
    I'm sorry, but the images are not visible. (Not here anyway).
    Is this a NAV 2009 matrix form? If so then it should have been posted in the NAV 2009 forum.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • RoddyMcLeanRoddyMcLean Member Posts: 101
    No classic matrix
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Obviously since you have not explained what is going on behind the scenes, this is pure guess work, but I would say that the code you use to calculate the numbers or to set the filters is in the wrong trigger.
    David Singleton
  • RoddyMcLeanRoddyMcLean Member Posts: 101
    Hi,

    I've used Account Schedules as a template so kept things as close as possible to product. When the user picks a view(schedule) the following code is run: -
    <Control1100361003> - OnValidate()
    //ITG0175 >>
    AccSchedManagement.CheckName(CurrentSchedName);
    AccSchedManagement.CheckUserSchedule(CurrentSchedName);
    SETFILTER("Budget Filter", CurrentSchedName);
    //ITG0175 <<
    
    <Control1100361003> - OnAfterValidate()
    //ITG0175 >>
    CurrForm.SAVERECORD;
    AccSchedManagement.SetName(CurrentSchedName,Rec);
    IF AccSchedName.GET(CurrentSchedName) THEN
      IF (AccSchedName."Default Column Layout" <> '') AND
         (CurrentColumnName <> AccSchedName."Default Column Layout")
      THEN BEGIN
        CurrentColumnName := AccSchedName."Default Column Layout";
        AccSchedManagement.CopyColumnsToTemp(CurrentColumnName,TempColumnLayout);
        AccSchedManagement.SetColumnName(CurrentColumnName,CurrForm.AccSchedMatrix.MatrixRec);
      END;
    AccSchedManagement.CheckAnalysisView(CurrentSchedName,CurrentColumnName,TRUE);
    
    IF AccSchedName."Analysis View Name" <> AnalysisView.Code THEN BEGIN
      PrevAnalysisView := AnalysisView;
      IF AccSchedName."Analysis View Name" <> '' THEN
        AnalysisView.GET(AccSchedName."Analysis View Name")
      ELSE BEGIN
        CLEAR(AnalysisView);
        AnalysisView."Dimension 1 Code" := GLSetup."Global Dimension 1 Code";
        AnalysisView."Dimension 2 Code" := GLSetup."Global Dimension 2 Code";
      END;
      IF PrevAnalysisView."Dimension 1 Code" <> AnalysisView."Dimension 1 Code" THEN
        SETRANGE("Dimension 1 Filter");
      IF PrevAnalysisView."Dimension 2 Code" <> AnalysisView."Dimension 2 Code" THEN
        SETRANGE("Dimension 2 Filter");
      IF PrevAnalysisView."Dimension 3 Code" <> AnalysisView."Dimension 3 Code" THEN
        SETRANGE("Dimension 3 Filter");
      IF PrevAnalysisView."Dimension 4 Code" <> AnalysisView."Dimension 4 Code" THEN
        SETRANGE("Dimension 4 Filter");
    END;
    
    CurrForm.Dim1Filter.ENABLED := AnalysisView."Dimension 1 Code" <> '';
    CurrForm.Dim2Filter.ENABLED := AnalysisView."Dimension 2 Code" <> '';
    CurrForm.Dim3Filter.ENABLED := AnalysisView."Dimension 3 Code" <> '';
    CurrForm.Dim4Filter.ENABLED := AnalysisView."Dimension 4 Code" <> '';
    
    //Note, I put the following 2 lines in, removing them makes no difference to problem: -
    TempColumnLayout.FIND('-'); 
    CurrForm.AccSchedMatrix.MatrixRec := TempColumnLayout;
    
    CurrForm.UPDATE(FALSE);
    CurrForm.UPDATECONTROLS;
    //ITG0175 <<
    


    On the Matrix form, the account schedule codeunit is run as per standard and I've put my calculations in there: -
    AccSchedMatrix - OnAfterGetRecord()
    IF Totaling = '' THEN
      ColumnValue := 0
    ELSE
      ColumnValue :=
        AccSchedManagement.CalcCell(Rec,CurrForm.AccSchedMatrix.MatrixRec,UseAmtsInAddCurr);
    

    So in codeunit 8, I've added a block sticking close to standard NAV practise: -
            ELSE
              //NAV2CISRM
              IF ColumnLayout."Calc Type" = ColumnLayout."Calc Type"::Adjustment THEN BEGIN
                WITH CVRAnalysisViewEntry DO BEGIN
                  SETRANGE("Analysis View Code",AccSchedName."Analysis View Name");
                  IF GLAcc.Totaling = '' THEN
                    SETRANGE("G/L Account No.",GLAcc."No.")
                  ELSE
                    SETFILTER("G/L Account No.",GLAcc.Totaling);
                  GLAcc.COPYFILTER("Date Filter","Posting Date");
                  AccSchedLine.COPYFILTER("Business Unit Filter","Business Unit Code");
                  AccSchedLine.COPYFILTER("Dimension 1 Filter","Dimension 1 Value Code");
                  AccSchedLine.COPYFILTER("Dimension 2 Filter","Dimension 2 Value Code");
                  AccSchedLine.COPYFILTER("Dimension 3 Filter","Dimension 3 Value Code");
                  AccSchedLine.COPYFILTER("Dimension 4 Filter","Dimension 4 Value Code");
                  FILTERGROUP(2);
                  SETFILTER("Dimension 1 Value Code",GetDimTotalingFilter(1,AccSchedLine."Dimension 1 Totaling"));
                  SETFILTER("Dimension 2 Value Code",GetDimTotalingFilter(2,AccSchedLine."Dimension 2 Totaling"));
                  SETFILTER("Dimension 3 Value Code",GetDimTotalingFilter(3,AccSchedLine."Dimension 3 Totaling"));
                  SETFILTER("Dimension 4 Value Code",GetDimTotalingFilter(4,AccSchedLine."Dimension 4 Totaling"));
                  FILTERGROUP(6);
                  SETFILTER("Dimension 1 Value Code",GetDimTotalingFilter(1,ColumnLayout."Dimension 1 Totaling"));
                  SETFILTER("Dimension 2 Value Code",GetDimTotalingFilter(2,ColumnLayout."Dimension 2 Totaling"));
                  SETFILTER("Dimension 3 Value Code",GetDimTotalingFilter(3,ColumnLayout."Dimension 3 Totaling"));
                  SETFILTER("Dimension 4 Value Code",GetDimTotalingFilter(4,ColumnLayout."Dimension 4 Totaling"));
                  SETFILTER("Business Unit Code",ColumnLayout."Business Unit Totaling");
                  FILTERGROUP(0);
    
                  CASE AmountType OF
                     AmountType::"Net Amount" :
                      BEGIN
                        IF CalcAddCurr THEN BEGIN
                          CALCSUMS("Add.-Curr. Amount");
                          ColValue := "Add.-Curr. Amount";
                        END ELSE BEGIN
                          CALCSUMS(Amount);
                          ColValue := Amount;
                        END;
                        Balance := ColValue;
                      END;
                    AmountType::"Debit Amount" :
                      BEGIN
                        IF CalcAddCurr THEN BEGIN
                          IF TestBalance THEN BEGIN
                            CALCSUMS("Add.-Curr. Debit Amount","Add.-Curr. Amount");
                            Balance := "Add.-Curr. Amount";
                          END ELSE
                            CALCSUMS("Add.-Curr. Debit Amount");
                          ColValue := "Add.-Curr. Debit Amount";
                        END ELSE BEGIN
                          IF TestBalance THEN BEGIN
                            CALCSUMS("Debit Amount",Amount);
                            Balance := Amount;
                          END ELSE
                            CALCSUMS("Debit Amount");
                          ColValue := "Debit Amount";
                        END;
                      END;
                    AmountType::"Credit Amount" :
                      BEGIN
                        IF CalcAddCurr THEN BEGIN
                          IF TestBalance THEN BEGIN
                            CALCSUMS("Add.-Curr. Credit Amount","Add.-Curr. Amount");
                            Balance := "Add.-Curr. Amount";
                          END ELSE
                            CALCSUMS("Add.-Curr. Credit Amount");
                          ColValue := "Add.-Curr. Credit Amount";
                        END ELSE BEGIN
                          IF TestBalance THEN BEGIN
                            CALCSUMS("Credit Amount",Amount);
                            Balance := Amount;
                          END ELSE
                            CALCSUMS("Credit Amount");
                          ColValue := "Credit Amount";
                        END;
                      END;
                  END;
                END;
              END ELSE BEGIN
                IF ((ColumnLayout."Calc Type" = ColumnLayout."Calc Type"::Committed)
                OR (ColumnLayout."Calc Type" = ColumnLayout."Calc Type"::Accrued)) THEN BEGIN
                  WITH PurchAnalysisViewEntry DO BEGIN
                    SETRANGE("Analysis View Code",AccSchedName."Analysis View Name");
                    GLAcc.COPYFILTER("Date Filter","Posting Date");
                    AccSchedLine.COPYFILTER("Dimension 1 Filter","Dimension 1 Value Code");
                    AccSchedLine.COPYFILTER("Dimension 2 Filter","Dimension 2 Value Code");
                    AccSchedLine.COPYFILTER("Dimension 3 Filter","Dimension 3 Value Code");
                    AccSchedLine.COPYFILTER("Dimension 4 Filter","Dimension 4 Value Code");
                    FILTERGROUP(2);
                    SETFILTER("Dimension 1 Value Code",GetDimTotalingFilter(1,AccSchedLine."Dimension 1 Totaling"));
                    SETFILTER("Dimension 2 Value Code",GetDimTotalingFilter(2,AccSchedLine."Dimension 2 Totaling"));
                    SETFILTER("Dimension 3 Value Code",GetDimTotalingFilter(3,AccSchedLine."Dimension 3 Totaling"));
                    SETFILTER("Dimension 4 Value Code",GetDimTotalingFilter(4,AccSchedLine."Dimension 4 Totaling"));
                    FILTERGROUP(6);
                    SETFILTER("Dimension 1 Value Code",GetDimTotalingFilter(1,ColumnLayout."Dimension 1 Totaling"));
                    SETFILTER("Dimension 2 Value Code",GetDimTotalingFilter(2,ColumnLayout."Dimension 2 Totaling"));
                    SETFILTER("Dimension 3 Value Code",GetDimTotalingFilter(3,ColumnLayout."Dimension 3 Totaling"));
                    SETFILTER("Dimension 4 Value Code",GetDimTotalingFilter(4,ColumnLayout."Dimension 4 Totaling"));
                    FILTERGROUP(0);
    
                    IF (ColumnLayout."Calc Type" = ColumnLayout."Calc Type"::Accrued) THEN BEGIN
                      CALCSUMS(Accrued);
                      ColValue := Accrued;
                    END ELSE BEGIN
                      CALCSUMS(Committed);
                      ColValue := Committed;
                    END;
    
                    Balance := ColValue;
                  END;
                END ELSE BEGIN
              //NAV2CISRM
    

    Sorry, this is a lot of code. I'm beginning to wonder if matrix forms have a few flaws themselves.

    Regards
    Roddy
  • KalleSoftKalleSoft Member Posts: 10
    You have to change the code in the SetColumnName function in the "AccSchedManagement" codeunit (8) as follows.

    ColumnLayout.RESET;
    ColumnLayout.FILTERGROUP(2);
    ColumnLayout.SETRANGE("Column Layout Name",CurrentColumnName);
    ColumnLayout.FILTERGROUP(0);
    // Delete the following line.
    IF ColumnLayout.FIND('-') THEN; <--- delete this line

    :D
    - KS -
  • RoddyMcLeanRoddyMcLean Member Posts: 101
    Thanks,

    I appreciate someone getting back. I'd found my way round - eventually.

    Roddy
Sign In or Register to comment.