Wow,
Thank you so much it works
I was trying to test when user is trying to post with changed dimension in batch
codeunit 60004 ChecJrnBeforepost
{
[EventSubscriber(ObjectType::Codeunit, codeunit::"Gen. Jnl.-Post Batch", 'OnBeforePostGenJnlLine', '', false, false)]
procedure CheckDim(var GenJournalLine: Record "Gen. Journal Line")
var
GenJournalTemplate: Record "Gen. Journal Template";
GenJournalBatch: Record "Gen. Journal Batch";
begin
GenJournalTemplate.Get(GenJournalTemplate.Name);
GenJournalBatch.Get(GenJournalTemplate.Name, GenJournalBatch.Name);
GenJournalLine.SetRange("Journal Template Name", GenJournalLine."Journal Template Name");
GenJournalLine.SetRange("Journal Batch Name", GenJournalLine."Journal Batch Name");
if GenJournalLine.FindFirst() then begin
if GenJournalLine."Bal. Gen. Bus. Posting Group" <> GenJournalBatch."Shortcut Dimension 1 Code" then
Error('Dimension does not match');
end;
end;