Item Journal Line Table's Records are getting deleted by themselves.

mysamza
Member Posts: 66
I wrote this procedure what will take lines and add them to the Item Journal Line table at the click of a button called "Issue Material"
Here is the procedure;
procedure IssueMaterial(IncomingLine: Record "Purchase Requisition Line")
var
ItemCont: Record "Item Journal Line";
begin
IF ItemCont.FindLast then begin
ItemCont."Line No." := ItemCont."Line No." + 10000;
end;
with ItemCont do begin
ItemCont.Init();
ItemCont."Journal Template Name" := 'Item';
Validate("Item No.", IncomingLine."No.");
ItemCont."Posting Date" := WorkDate();
Validate("Location Code", IncomingLine.Location);
ItemCont."Entry Type" := ItemCont."Entry Type"::"Negative Adjmt.";
ItemCont."Journal Batch Name" := 'Default';
ItemCont."Line No." := IncomingLine."Line No.";
Validate(Quantity, IncomingLine.Quantity);
Validate(Amount, IncomingLine.Amount);
Validate("Unit Cost", IncomingLine."Unit Cost");
ItemCont.Insert();
end;
Message('%1 has been successfully created', IncomingLine."No.");
end;
Here is the code at the Action (Button) I wrote;
trigger OnAction()
var
codeunitcont: Codeunit "Purchase Req. Mgmt.";
PurchReqLine: Record "Purchase Requisition Line";
begin
CurrPage.SetSelectionFilter(PurchReqLine);
IF PurchReqLine.FindSet then
repeat
PurchReqLine.TestField(PurchReqLine.Location);
codeunitcont.IssueMaterial(PurchReqLine);
until PurchReqLine.Next = 0;
end;
It works fine. I get my lines moved to the Item Journal Table, however, once I restart the Tenant or Rebuild and Republish an extension my Item Journal Table loses its records!
Thank you for your advice on what could be the issue
Here is the procedure;
procedure IssueMaterial(IncomingLine: Record "Purchase Requisition Line")
var
ItemCont: Record "Item Journal Line";
begin
IF ItemCont.FindLast then begin
ItemCont."Line No." := ItemCont."Line No." + 10000;
end;
with ItemCont do begin
ItemCont.Init();
ItemCont."Journal Template Name" := 'Item';
Validate("Item No.", IncomingLine."No.");
ItemCont."Posting Date" := WorkDate();
Validate("Location Code", IncomingLine.Location);
ItemCont."Entry Type" := ItemCont."Entry Type"::"Negative Adjmt.";
ItemCont."Journal Batch Name" := 'Default';
ItemCont."Line No." := IncomingLine."Line No.";
Validate(Quantity, IncomingLine.Quantity);
Validate(Amount, IncomingLine.Amount);
Validate("Unit Cost", IncomingLine."Unit Cost");
ItemCont.Insert();
end;
Message('%1 has been successfully created', IncomingLine."No.");
end;
Here is the code at the Action (Button) I wrote;
trigger OnAction()
var
codeunitcont: Codeunit "Purchase Req. Mgmt.";
PurchReqLine: Record "Purchase Requisition Line";
begin
CurrPage.SetSelectionFilter(PurchReqLine);
IF PurchReqLine.FindSet then
repeat
PurchReqLine.TestField(PurchReqLine.Location);
codeunitcont.IssueMaterial(PurchReqLine);
until PurchReqLine.Next = 0;
end;
It works fine. I get my lines moved to the Item Journal Table, however, once I restart the Tenant or Rebuild and Republish an extension my Item Journal Table loses its records!
Thank you for your advice on what could be the issue
0
Answers
-
ItemCont.Init(); in your code may empty "Line No." field. Use SetUpNewLine function in table 83.1
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions