Table 6213 Sustainability Jnl. Batch

Sustainability, Microsoft.Sustainability.Journal

src/Apps/W1/Sustainability/app/src/Journal/SustainabilityJnlBatch.Table.al130 lines, Copyright (c) Microsoft Corporation. MIT

namespace Microsoft.Sustainability.Journal;using Microsoft.Foundation.AuditCodes;using Microsoft.Foundation.NoSeries;using Microsoft.Sustainability.Account;using System.Automation;table 6213 "Sustainability Jnl. Batch"{    Access = Public;    Caption = 'Sustainability Journal Batch';    DataClassification = CustomerContent;    DataPerCompany = true;    Extensible = true;    DataCaptionFields = Name, Description;    fields    {        field(1; "Journal Template Name"; Code[10])        {            Caption = 'Journal Template Name';            TableRelation = "Sustainability Jnl. Template";            NotBlank = true;        }        field(2; Name; Code[10])        {            Caption = 'Batch Name';            NotBlank = true;        }        field(3; Description; Text[100])        {            Caption = 'Description';        }        field(4; "No Series"; Code[20])        {            Caption = 'No. Series';            TableRelation = "No. Series";        }        field(5; "Emission Scope"; Enum "Emission Scope")        {            Caption = 'Emission Scope';        }        field(6; "Source Code"; Code[10])        {            Caption = 'Source Code';            TableRelation = "Source Code";            trigger OnValidate()            var                SustainabilityJnlLine: Record "Sustainability Jnl. Line";            begin                if "Source Code" <> xRec."Source Code" then begin                    SustainabilityJnlLine.SetRange("Journal Template Name", "Journal Template Name");                    SustainabilityJnlLine.SetRange("Journal Batch Name", Name);                    SustainabilityJnlLine.ModifyAll("Source Code", "Source Code");                end;            end;        }        field(7; "Reason Code"; Code[10])        {            Caption = 'Reason Code';            TableRelation = "Reason Code";            trigger OnValidate()            var                SustainabilityJnlLine: Record "Sustainability Jnl. Line";            begin                if "Reason Code" <> xRec."Reason Code" then begin                    SustainabilityJnlLine.SetRange("Journal Template Name", "Journal Template Name");                    SustainabilityJnlLine.SetRange("Journal Batch Name", Name);                    SustainabilityJnlLine.ModifyAll("Reason Code", "Reason Code");                end;            end;        }        field(22; Recurring; Boolean)        {            CalcFormula = lookup("Sustainability Jnl. Template".Recurring where(Name = field("Journal Template Name")));            Caption = 'Recurring';            Editable = false;            FieldClass = FlowField;        }        field(40; "No. of Lines"; Integer)        {            CalcFormula = count("Sustainability Jnl. Line" where("Journal Template Name" = field("Journal Template Name"), "Journal Batch Name" = field(Name)));            Caption = 'No. of Lines';            Editable = false;            FieldClass = FlowField;            ToolTip = 'Specifies the number of lines in this journal batch.';        }    }    keys    {        key(PK; "Journal Template Name", Name)        {            Clustered = true;        }    }    trigger OnDelete()    var        SustainabilityJnlLine: Record "Sustainability Jnl. Line";    begin        ApprovalsMgmt.PreventDeletingRecordWithOpenApprovalEntry(Rec);        SustainabilityJnlLine.SetRange("Journal Template Name", "Journal Template Name");        SustainabilityJnlLine.SetRange("Journal Batch Name", Name);        SustainabilityJnlLine.DeleteAll(true);    end;    trigger OnInsert()    var        SustainabilityJnlTemplate: Record "Sustainability Jnl. Template";    begin        SustainabilityJnlTemplate.Get("Journal Template Name");    end;    trigger OnModify()    begin        ApprovalsMgmt.PreventModifyRecIfOpenApprovalEntryExistForCurrentUser(Rec);    end;    trigger OnRename()    begin        ApprovalsMgmt.OnRenameRecordInApprovalRequest(xRec.RecordId, RecordId);    end;    var        ApprovalsMgmt: Codeunit "Approvals Mgmt.";}