mibuso.com

Microsoft Business Solutions online community
It is currently Fri May 24, 2013 5:58 am

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: [Solved] Error importing code sample
PostPosted: Mon Oct 22, 2012 2:56 am 
Offline

Joined: Tue Jan 13, 2004 9:42 am
Posts: 53
Location: Jakarta
Country: Indonesia (id)
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


Last edited by Iqbal Febriano on Tue Oct 30, 2012 2:56 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Error importing code sample
PostPosted: Mon Oct 22, 2012 9:40 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Mon Nov 01, 2004 5:30 pm
Posts: 500
Location: Warnsveld
Country: Netherlands (nl)
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


Top
 Profile  
 
 Post subject: Re: Error importing code sample
PostPosted: Mon Oct 22, 2012 10:28 am 
Offline
Microsoft employee

Joined: Mon Dec 10, 2007 4:51 pm
Posts: 11
Location: MDCC
Country: Denmark (dk)
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


Top
 Profile  
 
 Post subject: Re: Error importing code sample
PostPosted: Mon Oct 22, 2012 1:42 pm 
Offline
Microsoft employee

Joined: Mon Dec 10, 2007 4:51 pm
Posts: 11
Location: MDCC
Country: Denmark (dk)
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.

Code: Select all
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


Top
 Profile  
 
 Post subject: Re: Error importing code sample
PostPosted: Tue Oct 30, 2012 2:50 pm 
Offline

Joined: Tue Jan 13, 2004 9:42 am
Posts: 53
Location: Jakarta
Country: Indonesia (id)
Thanks preitzel, it works :D

_________________
Be fast, be straight, be quiet


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: