Page 6342 Sust. Concept List

Sustainability, Microsoft.Sustainability.CRM

src/Apps/W1/Sustainability/app/src/CRM/SustConceptList.Page.al174 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.Sustainability.CRM;using Microsoft.Integration.Dataverse;using Microsoft.Sustainability.ESGReporting;page 6342 "Sust. Concept List"{    ApplicationArea = Suite;    Caption = 'Concept - Dataverse';    Editable = false;    PageType = List;    SourceTable = "Sust. Concept";    SourceTableView = sorting(Name);    UsageCategory = Lists;    layout    {        area(content)        {            repeater(Control2)            {                ShowCaption = false;                field(Name; Rec.Name)                {                    ApplicationArea = Suite;                    Caption = 'Name';                    StyleExpr = FirstColumnStyle;                    ToolTip = 'Specifies data from a corresponding field in a Dataverse entity. For more information about Dataverse, see Dataverse Help Center.';                }                field(ConceptDataType; Rec.ConceptDataType)                {                    ApplicationArea = Suite;                    Caption = 'Concept Data Type';                    StyleExpr = FirstColumnStyle;                    ToolTip = 'Specifies data from a corresponding field in a Dataverse entity. For more information about Dataverse, see Dataverse Help Center.';                }                field(Coupled; Coupled)                {                    ApplicationArea = Suite;                    Caption = 'Coupled';                    ToolTip = 'Specifies if the Dataverse record is coupled to Business Central.';                }            }        }    }    actions    {        area(processing)        {            action(CreateFromCRM)            {                ApplicationArea = Suite;                Caption = 'Create in Business Central';                Image = NewRow;                ToolTip = 'Generate the entity from the coupled Dataverse concept.';                trigger OnAction()                var                    CRMConcept: Record "Sust. Concept";                    CRMIntegrationManagement: Codeunit "CRM Integration Management";                begin                    CurrPage.SetSelectionFilter(CRMConcept);                    CRMIntegrationManagement.CreateNewRecordsFromCRM(CRMConcept);                end;            }            action(ShowOnlyUncoupled)            {                ApplicationArea = Suite;                Caption = 'Hide Coupled Concepts';                Image = FilterLines;                ToolTip = 'Do not show coupled concepts.';                trigger OnAction()                begin                    Rec.MarkedOnly(true);                end;            }            action(ShowAll)            {                ApplicationArea = Suite;                Caption = 'Show Coupled Concepts';                Image = ClearFilter;                ToolTip = 'Show coupled concepts.';                trigger OnAction()                begin                    Rec.MarkedOnly(false);                end;            }        }        area(Promoted)        {            group(Category_Process)            {                Caption = 'Process';                actionref(CreateFromCRM_Promoted; CreateFromCRM)                {                }                actionref(ShowOnlyUncoupled_Promoted; ShowOnlyUncoupled)                {                }                actionref(ShowAll_Promoted; ShowAll)                {                }            }        }    }    trigger OnInit()    begin        Codeunit.Run(Codeunit::"CRM Integration Management");        Commit();    end;    trigger OnOpenPage()    var        LookupCRMTables: Codeunit "Lookup CRM Tables";    begin        Rec.FilterGroup(4);        Rec.SetView(LookupCRMTables.GetIntegrationTableMappingView(Database::"Sust. Concept"));        Rec.FilterGroup(0);    end;    trigger OnAfterGetRecord()    begin        SetControlAppearance();    end;    var        CurrentlyCoupledCRMConcept: Record "Sust. Concept";        Coupled: Text;        FirstColumnStyle: Text;        CurrentLbl: Label 'Current';        StrongLbl: Label 'Strong';        NoLbl: Label 'No';        YesLbl: Label 'Yes';        NoneLbl: Label 'None';        SubordinateLbl: Label 'Subordinate';    local procedure SetControlAppearance()    var        CRMIntegrationRecord: Record "CRM Integration Record";        RecordID: RecordID;        EmptyRecordID: RecordID;    begin        if CRMIntegrationRecord.FindRecordIDFromID(Rec.ConceptId, Database::"Sust. ESG Concept", RecordID) then            if CurrentlyCoupledCRMConcept.ConceptId = Rec.ConceptId then begin                Coupled := CurrentLbl;                FirstColumnStyle := StrongLbl;                Rec.Mark(true);            end else begin                Coupled := YesLbl;                FirstColumnStyle := SubordinateLbl;                Rec.Mark(false);            end;        if RecordID = EmptyRecordID then begin            Coupled := NoLbl;            FirstColumnStyle := NoneLbl;            Rec.Mark(true);        end;    end;    procedure SetCurrentlyCoupledCRMConcept(CRMConcept: Record "Sust. Concept")    begin        CurrentlyCoupledCRMConcept := CRMConcept;    end;}