microsoft / ALAppExtensions

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

[Event Request] Page 954 "Manager Time Sheet by Job" - OnBeforeApproveLines #27033

Open massnicolas19 opened 1 month ago

massnicolas19 commented 1 month ago

Describe the request

Hello,

We need a new event in page 954 "Manager Time Sheet by Job" in procedure local procedure ApproveLines(). Here is the current code :

local procedure ApproveLines()
    var
        "Action": Option "Approve Selected","Approve All","Reopen Selected","Reopen All","Reject Selected","Reject All";
        ActionType: Option Approve,Reopen,Reject;
    begin
        case ShowDialog(ActionType::Approve) of
            1:
                Process(Action::"Approve All");
            2:
                Process(Action::"Approve Selected");
        end;
    end;

Here is now what we need to add our additional verification :

local procedure ApproveLines()
    var
        "Action": Option "Approve Selected","Approve All","Reopen Selected","Reopen All","Reject Selected","Reject All";
        ActionType: Option Approve,Reopen,Reject;
        isHandled: Boolean;
    begin
        OnBeforeApproveLines(Rec, isHandled);
        if IsHandled then
            exit;

        case ShowDialog(ActionType::Approve) of
            1:
                Process(Action::"Approve All");
            2:
                Process(Action::"Approve Selected");
        end;
    end;
[IntegrationEvent(false, false)]
    local procedure OnBeforeApproveLines(var TimeSheetLine: Record "Time Sheet Line"; var IsHandled: Boolean);
    begin
    end;

Additional context

We need to perform an additional verification before approving the Time Sheet Lines. At the end of our code, we add a popup to either go back or proceed with the approval anyway.

We also add this verification in Page 973 "Time Sheet Card" in procedure local procedure SubmitLines(). In this procedure we can skip the code if needed thanks to event OnBeforeSubmitLines(Rec, IsHandled).

local procedure SubmitLines()
    var
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeSubmitLines(Rec, IsHandled);
        if IsHandled then
            exit;

        if not CheckResourceEmployment(RefActionType::Submit, Rec."Resource No.") then
            if TimeSheetApprovalMgt.ConfirmAction(RefActionType::Submit) then
                Process(RefActionType::Submit);
    end;

Internal work item: AB#545028