I have made a report for processing data from Employee Absence table to a Employee Absence Journal Line.
I simply cannot get the data over, as it complains about the Batch name being empty.
Can anyone see from the code, where I have gone wrong:
Employee Absence - OnPreDataItem()
EmpBatch.GET(EmpJournal."Journal Batch Name");
NextLineNo := 0;
Employee Absence - OnAfterGetRecord()
WITH EmpJournal DO BEGIN
IF NextLineNo = 0 THEN BEGIN
LOCKTABLE;
SETRANGE("Journal Batch Name","Journal Batch Name");
IF FIND('+') THEN
NextLineNo := "Line No.";
END;
NextLineNo := NextLineNo + 1;
INIT;
"Line No." := NextLineNo;
//other code in here, that shouldn't affect the error message!!!
INSERT(TRUE);
END;
Many thanks
Ann
0
Comments
Well, actualy I have, but I've made these myself
If you use the debugger, where exactly does the error occur?
Does this piece of code go OK?
EmpBatch.GET(EmpJournal."Journal Batch Name");
I am asking this because on first sight I cannot see the problem
However, do I comment it out, it breaks on Emp Absence Jnl Line table on the trigger OnInsert, where I have AbsenceJnlBatch.Get("Journal Batch Name").
Thats why I am lost!
How do you start this report? Have you thought about putting the journal batch code in a variable and put it on the request form?
You have to determine where you want to get the batch from.
Is the EmpJournal record populated in the OnPreDataIem or is it empty?
EmpBatch.GET(EmpJournal."Journal Batch Name");
I hope this give you some clues as to where to start searching.
Needing a batch and template for journals is standard Navision functionality. What I usually do is give the user a place to enter a default for both in a setup table and populate the fields with those values.
You can also turn on the debugger and open a standard Journal, and follow standard Navision code to populate the batch and template. That should give you some ideas as to how to develop that.
RIS Plus, LLC
This is only for journals that are not directly posted, otherwise you can post a journal line without Template/Batch/Line No.
Look at codeunit 80 for example, no templates/batches etc there
RIS Plus, LLC
Elementary my dear Watson
RIS Plus, LLC
I just wanted to explain that it can be done without.
I see you've read you Sherlock Holmes 8)
This is getting another highjacked topic...
There needs to be code in between the INIT and the INSERT:
INIT;
"batch name" := '..............
INSERT(true);