Error importing code sample

Iqbal_FebrianoIqbal_Febriano Member Posts: 66
edited 2012-10-30 in NAV Three Tier
Hi all,

I was trying to import the code shown in Cash Flow Chart Example for NAV 2013. I got error message "OnDataPointClicked=VAR is not an option". Kindly advise what should I do to overcome this error
Be fast, be straight, be quiet

Answers

  • lvanvugtlvanvugt Member Posts: 774
    Hi Iqbal,

    Guess you toke the exmaple from here Cash Flow Chart Example?
    Did you create/load all the objects as displayed on this example?
    And (maybe very stupid question) you did do this on NAV 2013 RTM?
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • preitzelpreitzel Member, Microsoft Employee Posts: 12
    Hi Iqbal,

    It's the example in the MSDN that is wrong. It is now addressed to our UA people in MDCC who will update and fix the example ASAP.

    Thanks.
    Per Reitzel - Software Development Engineer - MDCC
  • preitzelpreitzel Member, Microsoft Employee Posts: 12
    Hi Iqbal,

    According to our UA it will take a few weeks before this change will be updated on MSDN. I therefore attach the two example objects here - Codeunit 50000 and Page 50000 - as it will be on MSDN when it gets updated later.
    OBJECT Codeunit 50000 Demo Cash Flow Chart Mgt.
    {
      OBJECT-PROPERTIES
      {
        Date=18-04-12;
        Time=16:11:09;
        Modified=Yes;
        Version List=Charts;
      }
      PROPERTIES
      {
        OnRun=BEGIN
              END;
    
      }
      CODE
      {
        VAR
          TextCust@1000 : TextConst 'ENU=Accounts Receivable';
          TextVend@1001 : TextConst 'ENU=Accounts Payable';
          TextBank@1002 : TextConst 'ENU=Bank Balances';
          TextTotal@1003 : TextConst 'ENU=Forecasted Balance';
          TextCredit@1004 : TextConst 'ENU=Credit Limit in Banks';
          TextDate@1005 : TextConst 'ENU=Date';
    
        PROCEDURE OnInitPage@6(VAR BusChartBuf@1000 : Record 485);
        BEGIN
        END;
    
        PROCEDURE GenerateData@3(VAR BusChartBuf@1000 : Record 485);
        VAR
          i@1007 : Integer;
          BankBalance@1006 : Decimal;
          CustNetChange@1005 : Decimal;
          VendNetChange@1004 : Decimal;
          TotalBalance@1003 : Decimal;
          BalanceDate@1002 : Date;
          BankCreditLimit@1001 : Decimal;
        BEGIN
          WITH BusChartBuf DO BEGIN
            Initialize;
            AddMeasure(TextCust,1,"Data Type"::Decimal,"Chart Type"::StackedColumn);
            AddMeasure(TextVend,2,"Data Type"::Decimal,"Chart Type"::StackedColumn);
            AddMeasure(TextTotal,3,"Data Type"::Decimal,"Chart Type"::Line);
            AddMeasure(TextCredit,4,"Data Type"::Decimal,"Chart Type"::StepLine);
            SetXAxis(TextDate,"Data Type"::DateTime);
            BalanceDate := WORKDATE - 1; // demo. Should be TODAY.
            CalcBankBalance(BalanceDate,TotalBalance,BankCreditLimit);
            FOR i := 1 TO 6  DO BEGIN  //  Generate 6 columns
              CustNetChange := CalcCustNetChange(BalanceDate,BalanceDate);
              VendNetChange := CalcVendNetChange(BalanceDate,BalanceDate);
              TotalBalance := TotalBalance + CustNetChange + VendNetChange;
    
              AddPeriodColumn(BalanceDate);  // X-Axis value
              SetValueByIndex(1 - 1,i - 1,CustNetChange); // zero indexed.
              SetValueByIndex(2 - 1,i - 1,VendNetChange);
              SetValueByIndex(3 - 1,i - 1,TotalBalance);
              SetValueByIndex(4 - 1,i - 1,BankCreditLimit);
              BalanceDate := BalanceDate + 1;
            END;
          END;
        END;
    
        PROCEDURE OnDataPointClicked@5(VAR BusChartBuf@1000 : Record 485);
        VAR
          VendLedgEntry@1001 : Record 25;
          DrillDownDate@1000000001 : Date;
        BEGIN
          DrillDownDate := WORKDATE + BusChartBuf."Drill-Down X Index" + 1; // ref. first balance date in GenerateData function
          CASE BusChartBuf."Drill-Down Measure Index" + 1 OF
            1 : // Customer
              DrillDownCust(DrillDownDate);
            2 : // Vendor
              DrillDownVend(DrillDownDate);
            4 : // Bank Credit limits
              DrillDownBank;
          END;
        END;
    
        LOCAL PROCEDURE CalcCustNetChange@1(FromDate@1000 : Date;ToDate@1001 : Date) : Decimal;
        VAR
          CustLedgEntry@1002 : Record 21;
          TotalRemainingAmount@1003 : Decimal;
        BEGIN
          WITH CustLedgEntry DO BEGIN
            SETCURRENTKEY(Open,"Due Date");
            SETRANGE(Open,TRUE);
            SETRANGE("Due Date",FromDate,ToDate);
            IF FIND('-') THEN
              REPEAT
                CALCFIELDS("Remaining Amt. (LCY)");
                TotalRemainingAmount := TotalRemainingAmount + "Remaining Amt. (LCY)";
              UNTIL NEXT = 0;
          END;
          EXIT(TotalRemainingAmount);
        END;
    
        LOCAL PROCEDURE CalcVendNetChange@4(FromDate@1000 : Date;ToDate@1001 : Date) : Decimal;
        VAR
          VendLedgEntry@1002 : Record 25;
          TotalRemainingAmount@1003 : Decimal;
        BEGIN
          WITH VendLedgEntry DO BEGIN
            SETCURRENTKEY(Open,"Due Date");
            SETRANGE(Open,TRUE);
            SETRANGE("Due Date",FromDate,ToDate);
            IF FIND('-') THEN
              REPEAT
                CALCFIELDS("Remaining Amt. (LCY)");
                TotalRemainingAmount := TotalRemainingAmount + "Remaining Amt. (LCY)";
              UNTIL NEXT = 0;
          END;
          EXIT(TotalRemainingAmount);
        END;
    
        LOCAL PROCEDURE CalcBankBalance@7(EndDate@1000 : Date;VAR TotalBalance@1003 : Decimal;VAR BankCreditLimit@1002 : Decimal);
        VAR
          BankAcc@1001 : Record 270;
        BEGIN
          WITH BankAcc DO BEGIN
            SETFILTER("Date Filter",'..%1',EndDate);
            IF FIND('-') THEN
              REPEAT
                CALCFIELDS("Balance at Date (LCY)");
                TotalBalance := TotalBalance + "Balance at Date (LCY)";
                BankCreditLimit := BankCreditLimit + BankAcc."Min. Balance";
              UNTIL NEXT = 0;
          END;
        END;
    
        LOCAL PROCEDURE DrillDownCust@1000000002(DrillDownDate@1000000000 : Date);
        VAR
          CustLedgEntry@1000000001 : Record 21;
        BEGIN
          CustLedgEntry.SETRANGE(Open,TRUE);
          CustLedgEntry.SETRANGE("Due Date",DrillDownDate,DrillDownDate);
          PAGE.RUNMODAL(PAGE::"Customer Ledger Entries",CustLedgEntry);
        END;
    
        LOCAL PROCEDURE DrillDownVend@1000000004(DrillDownDate@1000000000 : Date);
        VAR
          VendLedgEntry@1000000001 : Record 25;
        BEGIN
          VendLedgEntry.SETRANGE(Open,TRUE);
          VendLedgEntry.SETRANGE("Due Date",DrillDownDate,DrillDownDate);
          PAGE.RUNMODAL(PAGE::"Vendor Ledger Entries",VendLedgEntry);
        END;
    
        LOCAL PROCEDURE DrillDownBank@1000000005();
        BEGIN
          PAGE.RUNMODAL(PAGE::"Bank Account List");
        END;
    
        BEGIN
        END.
      }
    }
    OBJECT Page 50000 Demo Cash Flow Chart
    {
      OBJECT-PROPERTIES
      {
        Date=18-04-12;
        Time=15:57:04;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      CONTROLS
      {
        { 1   ;    ;Container ;
                    Name=Content;
                    ContainerType=ContentArea }
    
        { 2   ;1   ;Field     ;
                    Name=Chart;
                    ControlAddIn=[Microsoft.Dynamics.Nav.Client.BusinessChart;PublicKeyToken=31bf3856ad364e35] }
    
      }
      CODE
      {
        VAR
          BusinessChartBuffer@1000 : Record 485;
          DemoCashFlowChartMgt@1001 : Codeunit 50000;
    
        LOCAL PROCEDURE UpdateChart@2();
        BEGIN
          DemoCashFlowChartMgt.GenerateData(BusinessChartBuffer);
          BusinessChartBuffer.Update(CurrPage.Chart);
        END;
    
        EVENT Chart@-2::DataPointClicked@12(point@1000 : DotNet "'Microsoft.Dynamics.Nav.Client.BusinessChart.Model, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Microsoft.Dynamics.Nav.Client.BusinessChart.BusinessChartDataPoint");
        BEGIN
          BusinessChartBuffer.SetDrillDownIndexes(point);
          DemoCashFlowChartMgt.OnDataPointClicked(BusinessChartBuffer);
        END;
    
        EVENT Chart@-2::DataPointDoubleClicked@13(point@1000 : DotNet "'Microsoft.Dynamics.Nav.Client.BusinessChart.Model, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Microsoft.Dynamics.Nav.Client.BusinessChart.BusinessChartDataPoint"); 
        BEGIN
        END;
    
        EVENT Chart@-2::AddInReady@14();
        BEGIN
          UpdateChart;
        END;
    
        BEGIN
        END.
      }
    }
    
    Per Reitzel - Software Development Engineer - MDCC
  • Iqbal_FebrianoIqbal_Febriano Member Posts: 66
    Thanks preitzel, it works :D
    Be fast, be straight, be quiet
Sign In or Register to comment.