Delivery Note, Sum previous send quantity based on DN, Job No, and Job Task No. from Job Ledger Entr

Hi All,

I am new here, recommended by a friend.

My work place are preparing to launch Dynamics NAV 365 Client side manufacturing next week and they have asked me to write a few reports, I am a full C# Developer.

I am stuck on a particular report and I am not sure what I am doing wrong!

Basically I was asked to create a Delivery Note report,

These are the tables
Job Ledger Entry, Job Planning Line, Job Task, Job, and Job Site Address

Job Ledger Entry
Job No. = "2010"
Document No. = "DN000029"

Job Site Address
Code = "Main"

What I need is the report to sum any previous Delivery Notes based on the filter the user enters.


Imagine that the Quantity is 10 and last week we raised a delivery note saying that we were sending 2 items this should leave us 8 Remaining Qty, means that there will be 8 more items left to be shipped.

Now let`s say that I send another 2 more today I want the report to sum any previous sent items, so I can report back to the user how many is left,

My thoughts from the beginning was I will just report the Remaining Qty from Job Planning Lane but that`s not the case, here is why if they already shipped a few of these items I would like the code only to report anything before the current Filter Document No.

here is my code when I use it, it breaks my dataset, so I am not getting all the rows I was suppose to have

GlobalQTYToFollow is just a integer global I did

Job Ledger Entry - OnAfterGetRecord()

"Job Ledger Entry".RESET;

"Job Ledger Entry".SETCURRENTKEY("Job No.");
"Job Ledger Entry".SETRANGE("Job No.","Job No.");
"Job Ledger Entry".SETFILTER("Document No.",'<=%1',"Document No.");

GlobalQTYToFollow := GlobalQTYToFollow + "Job Ledger Entry".Quantity;
UNTIL "Job Ledger Entry".NEXT =0;

if any of you could please tell me what I am doing wrong

Many Thanks


  • JoaoPereira55JoaoPereira55 Member Posts: 2
    Hi again, for any of you out there, here is the code I came up with, not sure if its correct but the good thing is its working perfectly. and my boss is happy :)

    Job Ledger Entry - OnAfterGetRecord()

    JobLedgerEntry := "Job Ledger Entry";
    JobLedgerEntry.SETCURRENTKEY("Job No.");
    JobLedgerEntry.SETRANGE("Job No.","Job No.");
    JobLedgerEntry.SETFILTER("Document No.",'<=%1',"Document No.");


    GlobalQTYToFollow :=0;

    GlobalQTYToFollow:= GlobalQTYToFollow + "Job Ledger Entry".Quantity;
    UNTIL JobLedgerEntry.NEXT =0;

    JobLedgerEntry.Quantity := GlobalQTYToFollow;

    UNTIL JobLedgerEntry.NEXT =0;

    Job Ledger Entry - OnPostDataItem()

    Job Planning Line - OnPreDataItem()

    Job Planning Line - OnAfterGetRecord()

    JobPlanningLine := "Job Planning Line";
    JobPlanningLine.SETCURRENTKEY("Job No.","Job Task No.","No.");
    JobPlanningLine.SETRANGE("Job No.","Job Ledger Entry"."No.");
    JobPlanningLine.SETRANGE("Job Task No.","Job Ledger Entry"."Job Task No.");
    JobPlanningLine.SETRANGE("No.","Job Ledger Entry"."No.");

    Job Planning Line - OnPostDataItem()
Sign In or Register to comment.