Codeunit 9131 Check Assembly Document
src/Layers/W1/BaseApp/Assembly/Document/CheckAssemblyDocument.Codeunit.al78 lines, Copyright (c) Microsoft Corporation. MIT
// ------------------------------------------------------------------------------------------------// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.// ------------------------------------------------------------------------------------------------namespace Microsoft.Assembly.Document;using Microsoft.Inventory.Item;codeunit 9131 "Check Assembly Document"{ TableNo = "Assembly Header"; [EventSubscriber(ObjectType::Table, Database::Item, 'OnAfterCheckDocuments', '', false, false)] local procedure ItemOnBeforeCheckDocuments(Item: Record Item; CurrentFieldNo: Integer; CheckFieldNo: Integer; CheckFieldCaption: Text); begin CheckAssemblyHeaders(Item, CurrentFieldNo, CheckFieldNo, CheckFieldCaption); CheckAssemblyLines(Item, CurrentFieldNo, CheckFieldNo, CheckFieldCaption); end; internal procedure CheckAssemblyHeaders(var Item: Record Item; CurrentFieldNo: Integer; CheckFieldNo: Integer; CheckFieldCaption: Text) var AssemblyHeader: Record "Assembly Header"; IsHandled: Boolean; begin IsHandled := false; OnBeforeCheckAssemblyHeaders(Item, CurrentFieldNo, CheckFieldNo, CheckFieldCaption, IsHandled); if IsHandled then exit; AssemblyHeader.SetCurrentKey("Document Type", "Item No."); AssemblyHeader.SetRange("Item No.", Item."No."); if not AssemblyHeader.IsEmpty() then begin if CurrentFieldNo = 0 then Error( Item.GetCannotDeleteItemWithExistingDocumentLinesErr(), Item.TableCaption(), Item."No.", AssemblyHeader.TableCaption()); if CurrentFieldNo = CheckFieldNo then Error( Item.GetCannotChangeItemWithExistingDocumentLinesErr(), CheckFieldCaption, Item.TableCaption(), Item."No.", AssemblyHeader.TableCaption()); end; end; internal procedure CheckAssemblyLines(Item: Record Item; CurrentFieldNo: Integer; CheckFieldNo: Integer; CheckFieldCaption: Text) var AssemblyLine: Record "Assembly Line"; IsHandled: Boolean; begin IsHandled := false; OnBeforeCheckAssemblyLines(Item, CurrentFieldNo, CheckFieldNo, CheckFieldCaption, IsHandled); if IsHandled then exit; AssemblyLine.SetCurrentKey(Type, "No."); AssemblyLine.SetRange(Type, AssemblyLine.Type::Item); AssemblyLine.SetRange("No.", Item."No."); if not AssemblyLine.IsEmpty() then begin if CurrentFieldNo = 0 then Error( Item.GetCannotDeleteItemWithExistingDocumentLinesErr(), Item.TableCaption(), Item."No.", AssemblyLine.TableCaption()); if CurrentFieldNo = CheckFieldNo then Error( Item.GetCannotChangeItemWithExistingDocumentLinesErr(), CheckFieldCaption, Item.TableCaption(), Item."No.", AssemblyLine.TableCaption()); end; end; [IntegrationEvent(false, false)] local procedure OnBeforeCheckAssemblyHeaders(Item: Record Item; CurrentFieldNo: Integer; CheckFieldNo: Integer; CheckFieldCaption: Text; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeCheckAssemblyLines(Item: Record Item; CurrentFieldNo: Integer; CheckFieldNo: Integer; CheckFieldCaption: Text; var IsHandled: Boolean) begin end;}