Why do you need this change?
We want to be able to skip the checks for blocked service items and blocked/deleted items when invoicing service contracts, so that active contracts for items that were later blocked or deleted can still be invoiced.
Describe the request
We need two separate IsHandled event publishers in codeunit 5940 ServContractManagement, one in CheckServiceItemBlockedForAll and one in CheckItemServiceBlocked.
1: Add an event publisher OnBeforeCheckServiceItemBlockedForAll() to codeunit 5940 ServContractManagement with the following signature:
[IntegrationEvent(false, false)]
local procedure OnBeforeCheckServiceItemBlockedForAll(var ServiceContractLine: Record "Service Contract Line"; var IsHandled: Boolean)
begin
end;
which would be called as follows:
internal procedure CheckServiceItemBlockedForAll(var ServiceContractLine: Record "Service Contract Line")
var
ServiceItem: Record "Service Item";
IsHandled: Boolean; // << isHandled pattern
begin
IsHandled := false; // << isHandled pattern
OnBeforeCheckServiceItemBlockedForAll(ServiceContractLine, IsHandled); // << Call event
if IsHandled then // << isHandled pattern
exit; // << isHandled pattern
if ServiceContractLine."Service Item No." = '' then
exit;
ServiceItem.SetLoadFields(Blocked);
ServiceItem.Get(ServiceContractLine."Service Item No.");
ServiceItem.ErrorIfBlockedForAll();
end;
2: Add an event publisher OnBeforeCheckItemServiceBlocked() to codeunit 5940 ServContractManagement with the following signature:
[IntegrationEvent(false, false)]
local procedure OnBeforeCheckItemServiceBlocked(var ServiceContractLine: Record "Service Contract Line"; var IsHandled: Boolean)
begin
end;
which would be called as follows:
internal procedure CheckItemServiceBlocked(var ServiceContractLine: Record "Service Contract Line")
var
Item: Record Item;
ItemVariant: Record "Item Variant";
IsHandled: Boolean; // << isHandled pattern
begin
IsHandled := false; // << isHandled pattern
OnBeforeCheckItemServiceBlocked(ServiceContractLine, IsHandled); // << Call event
if IsHandled then // << isHandled pattern
exit; // << isHandled pattern
if ServiceContractLine."Item No." = '' then
exit;
Item.SetLoadFields(Blocked, "Service Blocked");
Item.Get(ServiceContractLine."Item No.");
Item.TestField(Blocked, false);
Item.TestField("Service Blocked", false);
if ServiceContractLine."Variant Code" <> '' then begin
ItemVariant.SetLoadFields(Blocked, "Service Blocked");
ItemVariant.Get(ServiceContractLine."Item No.", ServiceContractLine."Variant Code");
ItemVariant.TestField(Blocked, false);
ItemVariant.TestField("Service Blocked", false);
end;
end;
Why do you need this change?
We want to be able to skip the checks for blocked service items and blocked/deleted items when invoicing service contracts, so that active contracts for items that were later blocked or deleted can still be invoiced.
Describe the request
We need two separate IsHandled event publishers in codeunit 5940 ServContractManagement, one in CheckServiceItemBlockedForAll and one in CheckItemServiceBlocked.
1: Add an event publisher
OnBeforeCheckServiceItemBlockedForAll()to codeunit 5940 ServContractManagement with the following signature:which would be called as follows:
2: Add an event publisher
OnBeforeCheckItemServiceBlocked()to codeunit 5940 ServContractManagement with the following signature:which would be called as follows: