Page 171 Standard Sales Code Subform

Base Application, Microsoft.Sales.Document

src/Layers/W1/BaseApp/Sales/Document/StandardSalesCodeSubform.Page.al340 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.Sales.Document;using Microsoft.Finance.Dimension;using Microsoft.Utilities;using System.Environment.Configuration;/// <summary>/// Displays the line items subform for a standard sales code template./// </summary>page 171 "Standard Sales Code Subform"{    AutoSplitKey = true;    Caption = 'Lines';    DelayedInsert = true;    LinksAllowed = false;    MultipleNewLines = true;    PageType = ListPart;    SourceTable = "Standard Sales Line";    layout    {        area(content)        {            repeater(Control1)            {                ShowCaption = false;                field(Type; Rec.Type)                {                    ApplicationArea = Advanced;                    trigger OnValidate()                    begin                        UpdateTypeText();                        TypeOnAfterValidate();                    end;                }                field(FilteredTypeField; TypeAsText)                {                    ApplicationArea = Suite;                    Caption = 'Type';                    Editable = CurrPageIsEditable;                    LookupPageID = "Option Lookup List";                    TableRelation = "Option Lookup Buffer"."Option Caption" where("Lookup Type" = const(Sales));                    ToolTip = 'Specifies whether the line is for a general ledger account, item, fixed asset or item charge.';                    Visible = IsFoundation;                    trigger OnValidate()                    begin                        TempOptionLookupBuffer.SetCurrentType(Rec.Type.AsInteger());                        if TempOptionLookupBuffer.AutoCompleteLookup(TypeAsText, TempOptionLookupBuffer."Lookup Type"::Sales) then                            Rec.Validate(Type, TempOptionLookupBuffer.ID);                        TempOptionLookupBuffer.ValidateOption(TypeAsText);                        UpdateTypeText();                        TypeOnAfterValidate();                    end;                }                field("No."; Rec."No.")                {                    ApplicationArea = Suite;                    trigger OnValidate()                    begin                        if not ApplicationAreaMgmtFacade.IsFoundationEnabled() then                            exit;                        if Rec."No." = xRec."No." then                            exit;                        UpdateTypeText();                    end;                }                field("Variant Code"; Rec."Variant Code")                {                    ApplicationArea = Planning;                    Visible = false;                }                field(Description; Rec.Description)                {                    ApplicationArea = Suite;                    trigger OnValidate()                    var                        IsHandled: Boolean;                    begin                        if Rec.Description = xRec.Description then                            exit;                        IsHandled := false;                        OnValidateDescriptionOnBeforeChangeSalesLineType(Rec, IsHandled);                        if IsHandled then                            exit;                        if Rec."No." = '' then                            Rec.Type := Rec.Type::" ";                        UpdateTypeText();                    end;                }                field(Quantity; Rec.Quantity)                {                    ApplicationArea = Suite;                }                field("Unit of Measure Code"; Rec."Unit of Measure Code")                {                    ApplicationArea = Suite;                    Visible = false;                }                field("Amount Excl. VAT"; Rec."Amount Excl. VAT")                {                    ApplicationArea = Suite;                    Visible = false;                }                field("Shortcut Dimension 1 Code"; Rec."Shortcut Dimension 1 Code")                {                    ApplicationArea = Dimensions;                    Visible = DimVisible1;                }                field("Shortcut Dimension 2 Code"; Rec."Shortcut Dimension 2 Code")                {                    ApplicationArea = Dimensions;                    Visible = DimVisible2;                }                field("ShortcutDimCode[3]"; ShortcutDimCode[3])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,3';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(3),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible3;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(3, ShortcutDimCode[3]);                    end;                }                field("ShortcutDimCode[4]"; ShortcutDimCode[4])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,4';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(4),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible4;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(4, ShortcutDimCode[4]);                    end;                }                field("ShortcutDimCode[5]"; ShortcutDimCode[5])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,5';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(5),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible5;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(5, ShortcutDimCode[5]);                    end;                }                field("ShortcutDimCode[6]"; ShortcutDimCode[6])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,6';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(6),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible6;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(6, ShortcutDimCode[6]);                    end;                }                field("ShortcutDimCode[7]"; ShortcutDimCode[7])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,7';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(7),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible7;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(7, ShortcutDimCode[7]);                    end;                }                field("ShortcutDimCode[8]"; ShortcutDimCode[8])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,8';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(8),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible8;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(8, ShortcutDimCode[8]);                    end;                }            }        }    }    actions    {        area(processing)        {            group("&Line")            {                Caption = '&Line';                Image = Line;                action(Dimensions)                {                    AccessByPermission = TableData Dimension = R;                    ApplicationArea = Dimensions;                    Caption = 'Dimensions';                    Image = Dimensions;                    Scope = Repeater;                    ShortCutKey = 'Alt+D';                    ToolTip = 'View or edit dimensions, such as area, project, or department, that you can assign to sales and purchase documents to distribute costs and analyze transaction history.';                    trigger OnAction()                    begin                        Rec.ShowDimensions();                    end;                }            }        }    }    trigger OnAfterGetCurrRecord()    begin        CurrPageIsEditable := CurrPage.Editable;        UpdateTypeText();    end;    trigger OnAfterGetRecord()    begin        Rec.ShowShortcutDimCode(ShortcutDimCode);        UpdateTypeText();    end;    trigger OnInit()    begin        TempOptionLookupBuffer.FillLookupBuffer(TempOptionLookupBuffer."Lookup Type"::Sales);        IsFoundation := ApplicationAreaMgmtFacade.IsFoundationEnabled();    end;    trigger OnNewRecord(BelowxRec: Boolean)    begin        if ApplicationAreaMgmtFacade.IsAdvancedEnabled() then            Rec.Type := xRec.Type;        if ApplicationAreaMgmtFacade.IsFoundationEnabled() then            Rec.Type := Rec.Type::Item;        UpdateTypeText();        Clear(ShortcutDimCode);    end;    trigger OnInsertRecord(BelowxRec: Boolean): Boolean    begin        UpdateTypeText();    end;    trigger OnOpenPage()    begin        SetDimensionsVisibility();    end;    var        TempOptionLookupBuffer: Record "Option Lookup Buffer" temporary;        ApplicationAreaMgmtFacade: Codeunit "Application Area Mgmt. Facade";        TypeAsText: Text[30];        IsFoundation: Boolean;        CurrPageIsEditable: Boolean;    protected var        ShortcutDimCode: array[8] of Code[20];        DimVisible1: Boolean;        DimVisible2: Boolean;        DimVisible3: Boolean;        DimVisible4: Boolean;        DimVisible5: Boolean;        DimVisible6: Boolean;        DimVisible7: Boolean;        DimVisible8: Boolean;    local procedure TypeOnAfterValidate()    begin        Clear(ShortcutDimCode);    end;    /// <summary>    /// Updates the display text for the Type field based on the current record value.    /// </summary>    procedure UpdateTypeText()    var        RecRef: RecordRef;    begin        RecRef.GetTable(Rec);        TypeAsText := TempOptionLookupBuffer.FormatOption(RecRef.Field(Rec.FieldNo(Type)));    end;    local procedure SetDimensionsVisibility()    var        DimMgt: Codeunit DimensionManagement;    begin        DimVisible1 := false;        DimVisible2 := false;        DimVisible3 := false;        DimVisible4 := false;        DimVisible5 := false;        DimVisible6 := false;        DimVisible7 := false;        DimVisible8 := false;        DimMgt.UseShortcutDims(          DimVisible1, DimVisible2, DimVisible3, DimVisible4, DimVisible5, DimVisible6, DimVisible7, DimVisible8);        Clear(DimMgt);    end;    [IntegrationEvent(false, false)]    local procedure OnValidateDescriptionOnBeforeChangeSalesLineType(var StandardSalesLine: Record "Standard Sales Line"; var IsHandled: Boolean)    begin    end;}