Skip to content

[Event Request] codeunit 5940 - ServContractManagement - procedures CheckServiceItemBlockedForAll & CheckItemServiceBlocked #30342

Description

@LennartZeKVS

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    missing-infoThe issue misses information that prevents it from completion.

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions