microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
783 stars 620 forks source link

[Event Request] Codeunit 5720 "Item Reference Management" - OnEnterSalesItemReferenceOnAfterCalcShouldAssignDescription #27038

Closed 1languste closed 2 months ago

1languste commented 2 months ago

Describe the request

I want to handle whether the global item ref. description is assigned to the sales line. Therefore, I request the following event:

procedure EnterSalesItemReference(var SalesLine2: Record "Sales Line")
var
    IsHandled: Boolean;
    //NEW BEGIN
    ShouldAssignDescription: Boolean;
    //NEW END
begin
    IsHandled := false;
    OnBeforeEnterSalesItemReference(SalesLine2, GlobalItemReference, Found, IsHandled);
    if IsHandled then
        exit;

    if SalesLine2.Type = SalesLine2.Type::Item then begin
        FindItemReferenceForSalesLine(SalesLine2);

        if Found then begin
            SalesLine2."Item Reference No." := GlobalItemReference."Reference No.";
            SalesLine2."Item Reference Unit of Measure" := GlobalItemReference."Unit of Measure";
            SalesLine2."Item Reference Type" := GlobalItemReference."Reference Type";
            //NEW BEGIN
            ShouldAssignDescription := GlobalItemReference.Description <> '';
            OnEnterSalesItemReferenceOnAfterCalcShouldAssignDescription(SalesLine2, GlobalItemReference, ShouldAssignDescription);
            if ShouldAssignDescription then begin
            //NEW END
                SalesLine2.Description := GlobalItemReference.Description;
                SalesLine2."Description 2" := GlobalItemReference."Description 2";
            end;
            SalesLine2."Item Reference Type No." := GlobalItemReference."Reference Type No.";
            OnAfterSalesItemReferenceFound(SalesLine2, GlobalItemReference);
        end else begin
            //...
end;

[IntegrationEvent(false, false)]
local procedure OnEnterSalesItemReferenceOnAfterCalcShouldAssignDescription(var SalesLine: Record "Sales Line"; ItemReference: Record "Item Reference"; var ShouldAssignDescription: Boolean)
begin
end;

Additional context

I need the OnEnterPurchaseItemReferenceOnAfterCalcShouldAssignDescription for the Sales Item function, to handle whether the Global Item Ref. description should be assigned or not. Internal work item: AB#544567

JakovljevicDusan commented 2 months ago

To be more flexible, variable SalesLineBeforeChanges added to existing events. So, Descriptions can be restored using it.

JesperSchulz commented 2 months ago

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

Build ID: 23752.