Register record of Sales Shipment/Invoice Line

edo906edo906 Member Posts: 7
edited 2020-09-24 in NAV Three Tier
Hi,

I have a project for NAV2013R2 where i have to take some records of sales shipment line and sales invoice line and write them on custom table(with page action). Before this, the user can filter (when push the action page) records for POSTING DATE only month and year(for example if user set 04/2020, "process" write on the custom table only INVOICE OR DDT with POSTING DATE from 01/04/2020 to 30/04/2020)

How can do this??

Thanks so much and sorry for my bad english

Answers

  • AlexeyShaminAlexeyShamin Member Posts: 80
    edited 2020-09-24
    Hello!
    small example:
    BeginDate - date
    StartDate - Date
    SalesInvLine - record on Sales Invoice Line
    FilterDate - set by user/ Example 01/04/2020

    BeginDate := CALCDATE('<-CM>', FilterDate);
    EndDate := CALCDATE('<-CM>', FilterDate);


    SalesInvLine.RESET;
    SalesInvLine .SETFILTER("Posting Date", '%1..%2', BeginDate, EndDate)
    IF SalesInvLine.FINDSET THEN
    REPEAT

    UNTIL SalesInvLine.NEXT = 0;
  • edo906edo906 Member Posts: 7
    Thanks for answer!! :)

    But with your code, there is an error:

    bhukrmuhzn8r.png

    and then the date that set by user on filter on request page is only(Month/Year) without days... for example if i set 04/2020, take records of all April... if i set 05/2020, take records of all May


    Thanks so much







    Hello!
    small example:
    BeginDate - date
    StartDate - Date
    SalesInvLine - record on Sales Invoice Line
    FilterDate - set by user/ Example 01/04/2020

    BeginDate := CALCDATE('<-CM>', FilterDate);
    EndDate := CALCDATE('<-CM>', FilterDate);


    SalesInvLine.RESET;
    SalesInvLine .SETFILTER("Posting Date", '%1..%2', BeginDate, EndDate)
    IF SalesInvLine.FINDSET THEN
    REPEAT

    UNTIL SalesInvLine.NEXT = 0;

  • AlexeyShaminAlexeyShamin Member Posts: 80
    User input month and year in different variables?
  • edo906edo906 Member Posts: 7
    Yes, without days. Only month and year and then take all records in that month of the year
    User input month and year in different variables?

  • AlexeyShaminAlexeyShamin Member Posts: 80
    UserMonth - variable with month
    UserYear - variable with year

    BeginDate := DMY2Date(1, UserMonth,UserYear);
    EndDate := CALCDATE('<CM>', BeginDate);

    find out help about this function
    https://docs.microsoft.com/en-us/dynamics-nav/dmy2date-function--date-
  • edo906edo906 Member Posts: 7
    edited 2020-09-24
    Thanks!! But for transfer few fields to other table? I try this code on page action:
    IF saleshipline.FINDSET THEN
    REPEAT
      ledger.ID_TRANSPORT_DOCUMENT := saleshipline."Document No.";
      ledger.ROW_TRANSPORT_DOCUMENT := saleshipline."Line No.";
      ledger.ID_INVOICE := saleshipline."Document No.";
      ledger.ROW_INVOICE := saleshipline."Line No.";
      ledger.INSERT;
    UNTIL saleshipline.NEXT = 0;
    

    Var:

    Name DataType Subtype Length
    saleshipline Record Sales Shipment Line
    ledger Record Ledger

    But it didn't work.

    Help me please

    Thanks

    UserMonth - variable with month
    UserYear - variable with year

    BeginDate := DMY2Date(1, UserMonth,UserYear);
    EndDate := CALCDATE('<CM>', BeginDate);

    find out help about this function
    https://docs.microsoft.com/en-us/dynamics-nav/dmy2date-function--date-

Sign In or Register to comment.