Hi I want to post Item journal line through Al code,
For posting date, entry type, item number and quantity.
So after posting I want to get that line in item ledger entries, how can we do it through Al code please help.
Thankyou
Hi I want to post Item journal line through Al code,
For posting date, entry type, item number and quantity.
So after posting I want to get that line in item ledger entries, how can we do it through Al code please help.
Thankyou
Thankyou now it's working for me.
Please validate Item No.
Line.Validate("Item No.",'1906-S');
When I am posting now I am getting this issue:
Gen. Prod. Posting Group must have a value in Item Journal Line: Journal Template Name=, Journal Batch Name=, Line No.=0. It cannot be zero or empty.
As you mentioned Itemjournalbatch and journal line what to assign them like is it Recorde or codeunit?
And where to define line no
Can you update in my code?
Thankyou
You need to define, Template name, Batch name and Line no. field as well.
pageextension 50102 "ItemJournal line" extends "Item List"
{
actions
{
addfirst(processing)
{
action(Test)
{
Caption = 'Post something';
ApplicationArea = all;
trigger OnAction()
var
GLPost: Codeunit "Item Jnl.-Post Line";
Line: Record "Item Journal Line";
begin
Line.Init();
Line."Posting Date" := TODAY();
Line."Entry Type" := Line."Entry Type"::"Negative Adjmt.";
Line."Document No." := 'A2134';
Line."Item No." := '1906-S';
Line.Description := 'Item Quantity';
Line.Quantity := 3;
Line.Amount := 70;
GLPost.RunWithCheck(Line);
end;
}
}
}
}
as I has something like this anything to update?
Hi,
You can try below code
// Define variables for journal template name and batch name JournalTemplateName := 'Inventory'; BatchName := 'Batch1'; // Create a new Item Journal batch ItemJournalBatch.SETRANGE("Journal Template Name", JournalTemplateName); ItemJournalBatch.SETRANGE("Batch Name", BatchName); ItemJournalBatch.INSERT; // Create a new journal line JournalLine.SETRANGE("Journal Template Name", JournalTemplateName); JournalLine.SETRANGE("Journal Batch Name", BatchName); JournalLine.INSERT; // Populate the journal line fields JournalLine."Gen. Bus. Posting Group" := Item."Gen. Bus. Posting Group"; JournalLine."Posting Date" := WORKDATE; JournalLine."Item Ledger Entry Type" := ItemLedgerEntryType::Positive; JournalLine."Document Type" := DocumentType::Item; JournalLine."Item No." := 'ITEM001'; JournalLine."Location Code" := 'WH01'; JournalLine.Quantity := 10; // Post the Item Journal batch ItemJournalBatch.VALIDATE("No. of Journal Lines"); ItemJournalBatch.RUN;
André Arnaud de Cal... 291,391 Super User 2024 Season 2
Martin Dráb 230,445 Most Valuable Professional
nmaenpaa 101,156