microsoft / ALAppExtensions

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

[Event Request] table 167 Job - OnUpdateCostPricesOnRelatedJobPlanningLinesOnBeforeConfirmUpdate #26680

Closed pri-kise closed 1 day ago

pri-kise commented 2 weeks ago

Describe the request

Could you please add the following event OnUpdateCostPricesOnRelatedJobPlanningLinesOnBeforeConfirmUpdate?

We want to skip the UpdateOfCostPrices in some processes via manual event binding.

local procedure UpdateCostPricesOnRelatedJobPlanningLines(var Job: Record Job)
var
    JobPlanningLine: Record "Job Planning Line";
    ConfirmManagement: Codeunit "Confirm Management";
    ConfirmResult: Boolean;
    IsHandled: Boolean;
begin
    JobPlanningLine.SetRange("Job No.", Job."No.");
    JobPlanningLine.SetFilter(Type, '<>%1', JobPlanningLine.Type::Text);
    JobPlanningLine.SetFilter("No.", '<>%1', '');
    if JobPlanningLine.IsEmpty() then
        exit;

    //>>> Change for Event
    //-if not Job.GetHideValidationDialog() then
    //-    if not ConfirmManagement.GetResponseOrDefault(UpdateCostPricesOnRelatedLinesQst, true) then
    //-        exit;        
    OnUpdateCostPricesOnRelatedJobPlanningLinesOnBeforeConfirmUpdate(Job, ConfirmResult, IsHandled);
    if not IsHandled then begin
        ConfirmResult := Job.GetHideValidationDialog();
        if not ConfirmResult then
            ConfirmResult := ConfirmManagement.GetResponseOrDefault(UpdateCostPricesOnRelatedLinesQst, true);   
    end;
    if not ConfirmResult then
        exit;
    //<<< Change for Event

    JobPlanningLine.FindSet(true);
    repeat
        JobPlanningLine."Line Amount" := 0;
        JobPlanningLine.SetJob(Job);
        JobPlanningLine.CopyFieldsFromJob();
        JobPlanningLine.UpdateAllAmounts();
        JobPlanningLine.Modify(true);
    until JobPlanningLine.Next() = 0;

    OnAfterUpdateCostPricesOnRelatedJobPlanningLines(Job);
end;```

```al
[IntegrationEvent(false, false)]
local procedure OnUpdateCostPricesOnRelatedJobPlanningLinesOnBeforeConfirmUpdate(var Job: Record Job; var ConfirmResult: Boolean; var IsHandled: Boolean)
begin
end;

Additional context

We want to skip the update of the cost and the prices in some processes via manual event binding. And we want to suppress any additional confirm in this processes. Internal work item: AB#538574

pri-kise commented 3 days ago

I had a bug in my refactoring example. I forgot a not.

I've updated the example above. to

    if not ConfirmResult then
        exit;

instead of

   if ConfirmResult then
        exit;
JesperSchulz commented 1 day 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: 21513.