[Event Request] Codeunit 181 "Copy Gen. Journal Mgt."
Why do you need this change?
We would like to have a possibility to ignore the FinishMessage and run automatic posting of the copied lines.
Describe the request
///
CheckIfCanBeCopied(PostedGenJournalLine);
if not GetCopyParameters(CopyGenJournalParameters, PostedGenJournalLine) then
exit;
PostedGenJournalLine.FindSet();
repeat
InsertGenJournalLine(PostedGenJournalLine, CopyGenJournalParameters);
until PostedGenJournalLine.Next() = 0;
// >>>
OnBeforeShowFinishMessage(PostedGenJournalLine.Count(), CopyGenJournalParameters, IsHandled);
if IsHandled then
exit;
// <<<
ShowFinishMessage(PostedGenJournalLine.Count(), CopyGenJournalParameters);
end;
// >>>
///
Alternatives evaluated
Existing events. CopyToGenJournal already raises OnAfterCheckIfCanBeCopied and OnAfterInsertGenJournalLine. Both fire before the loop finishes, so neither can influence the finish message, which comes after the last line is inserted. No other hook. ShowFinishMessage is a local procedure with no event inside or around it, so an extension cannot suppress or replace the prompt. Copying the codeunit. The only remaining option is to copy codeunit 181 into the extension, which is what we do today. That duplicates Microsoft logic, drifts with each release, and breaks other extensions' subscribers to the base events. We want to remove that copy.
Justification for the IsHandled pattern
Why not a standard event. The finish message is a user prompt that follows the standard flow. An extension that has already handled the copied lines, for example by posting them, needs to replace that step with nothing. A pure notification event such as OnAfter… can't do that, because the prompt would still appear. Why not a direct contribution. Posting copied lines automatically is a partner-specific behavior. It does not belong in the base product. Scope. The flag only skips the finish message. It does not change the copy result, so the standard behavior is unchanged if no subscriber sets it.
Performance considerations
Frequency. The event is raised once per copy action, after the insert loop, and not per line. That is a user-triggered, interactive action. Cost. With no subscriber, the cost is one event call and one Count() call that already exists today. With a subscriber, the cost is whatever that subscriber does, which the subscriber owns. There is no loop, database read or UI work added by the event itself.
Data sensitivity review
The event passes the line count and the Copy Gen. Journal Parameters record, which holds the target journal template and batch names and the user's copy settings, such as replacement dates and the reverse-sign option. It does not pass the posted journal lines or any customer, vendor or bank data. The record is passed by value, so subscribers can't change it.
Multiple-extension interaction
IsHandled is only ever set to true, never reset by the base code. If several subscribers run, the first one to set it wins, and later ones should check IsHandled and exit to avoid double work. If two extensions both want to take over the message, the second one is skipped. They would need to coordinate through the same subscriber convention, which is standard for IsHandled events. The effect of a conflict is limited. If any subscriber suppresses the message, the user sees no prompt. The copied lines are not affected. Because the event fires after the lines are inserted and before the message, a subscriber can also act on the copied lines without conflicting with other extensions' OnAfterInsertGenJournalLine subscribers.
Provide an implementation (optional)
- [ ] I will provide the implementation for this extensibility request
Hi @bogdangarkusha,
Thank you for your extensibility request. To help us process it efficiently, please update the issue to include the required information.
Missing Information:
- Alternatives evaluated: Identify existing events or alternative approaches considered and explain why they are insufficient.
- Justification for IsHandled pattern: Explain why a standard event, redesign, or direct contribution cannot support the scenario.
- Performance considerations: Describe the expected execution frequency and performance impact.
- Data sensitivity review: Confirm whether the proposed event exposes sensitive data.
- Multiple-extension interaction: Explain how conflicts between multiple subscribers would be handled or mitigated.
Please update the issue with the missing details. We'll automatically re-analyze once updated.
[!NOTE] Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.
[!TIP] Is the triage result incorrect? Reply with
/not-accurateand briefly explain what was wrong. Your feedback improves future responses.
Hi @bogdangarkusha,
Thank you for your extensibility request. To help us process it efficiently, please update the issue to include the required information.
Missing Information:
- Alternatives evaluated: Identify existing events or alternative approaches considered and explain why they are insufficient.
- Justification for IsHandled pattern: Explain why a standard event, redesign, or direct contribution cannot support the scenario.
- Performance considerations: Describe the expected execution frequency and performance impact.
- Data sensitivity review: Confirm whether the proposed event exposes sensitive data.
- Multiple-extension interaction: Explain how conflicts between multiple subscribers would be handled or mitigated.
Please update the issue with the missing details. We'll automatically re-analyze once updated.
[!NOTE] Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.
[!TIP] Is the triage result incorrect? Reply with
/not-accurateand briefly explain what was wrong. Your feedback improves future responses.
✅ Analysis complete - ready for further processing
Implementation:
Add an integration event in CopyToGenJournal before the finish message, allowing subscribers to suppress the message by setting IsHandled.
Location in CopyToGenJournal before ShowFinishMessage:
IsHandled := false;
OnCopyToGenJournalOnBeforeShowFinishMessage(PostedGenJournalLine.Count, CopyGenJournalParameters, IsHandled);
if IsHandled then
exit;
ShowFinishMessage(PostedGenJournalLine.Count, CopyGenJournalParameters);
Event Publisher (add at the end of the codeunit with other events):
[IntegrationEvent(false, false)]
local procedure OnCopyToGenJournalOnBeforeShowFinishMessage(LineCount: Integer; CopyGenJournalParameters: Record "Copy Gen. Journal Parameters"; var IsHandled: Boolean)
begin
end;
File: CopyGenJournalMgt.Codeunit.al
[!NOTE] Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.
[!TIP] Is the triage result incorrect? Reply with
/not-accurateand briefly explain what was wrong. Your feedback improves future responses.