Page 6297 Sust. ESG Standards

Sustainability, Microsoft.Sustainability.ESGReporting

src/Apps/W1/Sustainability/app/src/ESGReporting/SustESGStandards.Page.al220 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.ESGReporting;using Microsoft.Integration.Dataverse;using Microsoft.Sustainability.Setup;page 6297 "Sust. ESG Standards"{    Caption = 'ESG Standards';    PageType = List;    UsageCategory = Lists;    ApplicationArea = Basic, Suite;    SourceTable = "Sust. ESG Standard";    layout    {        area(content)        {            repeater(Control1)            {                ShowCaption = false;                field("No."; Rec."No.")                {                    ApplicationArea = Basic, Suite;                    ToolTip = 'Specifies the value of the No. field.';                    trigger OnAssistEdit()                    begin                        if Rec.AssistEdit(xRec) then                            CurrPage.Update();                    end;                }                field(Description; Rec.Description)                {                    ApplicationArea = Basic, Suite;                    ToolTip = 'Specifies the value of the Description field.';                }                field("Coupled to Dataverse"; Rec."Coupled to Dataverse")                {                    ApplicationArea = All;                    Visible = SustDataverseIntEnabled;                }            }        }        area(factboxes)        {            systempart(Links; Links)            {                ApplicationArea = RecordLinks;                Visible = false;            }            systempart(Notes; Notes)            {                ApplicationArea = Notes;                Visible = false;            }        }    }    actions    {        area(Navigation)        {            group(ActionGroupCRM)            {                Caption = 'Dataverse';                Visible = SustDataverseIntEnabled;                action(CRMGotoStandard)                {                    ApplicationArea = Suite;                    Caption = 'Standard';                    Image = CoupledItem;                    ToolTip = 'Open the coupled Dataverse standard.';                    trigger OnAction()                    var                        CRMIntegrationManagement: Codeunit "CRM Integration Management";                    begin                        CRMIntegrationManagement.ShowCRMEntityFromRecordID(Rec.RecordId());                    end;                }                action(CRMSynchronizeNow)                {                    AccessByPermission = TableData "CRM Integration Record" = IM;                    ApplicationArea = Suite;                    Caption = 'Synchronize';                    Image = Refresh;                    ToolTip = 'Send or get updated data to or from Dataverse.';                    trigger OnAction()                    var                        ESGStandard: Record "Sust. ESG Standard";                        CRMIntegrationManagement: Codeunit "CRM Integration Management";                        ESGStandardRecordRef: RecordRef;                    begin                        CurrPage.SetSelectionFilter(ESGStandard);                        ESGStandard.Next();                        if ESGStandard.Count = 1 then                            CRMIntegrationManagement.UpdateOneNow(ESGStandard.RecordId())                        else begin                            ESGStandardRecordRef.GetTable(ESGStandard);                            CRMIntegrationManagement.UpdateMultipleNow(ESGStandardRecordRef);                        end                    end;                }                group(Coupling)                {                    Caption = 'Coupling', Comment = 'Coupling is a noun';                    Image = LinkAccount;                    ToolTip = 'Create, change, or delete a coupling between the Business Central record and a Dataverse record.';                    action(ManageCRMCoupling)                    {                        AccessByPermission = TableData "CRM Integration Record" = IM;                        ApplicationArea = Suite;                        Caption = 'Set Up Coupling';                        Image = LinkAccount;                        ToolTip = 'Create or modify the coupling to a Dataverse assessment.';                        trigger OnAction()                        var                            CRMIntegrationManagement: Codeunit "CRM Integration Management";                        begin                            CRMIntegrationManagement.DefineCoupling(Rec.RecordId());                        end;                    }                    action(DeleteCRMCoupling)                    {                        AccessByPermission = TableData "CRM Integration Record" = D;                        ApplicationArea = Suite;                        Caption = 'Delete Coupling';                        Enabled = CRMIsCoupledToRecord;                        Image = UnLinkAccount;                        ToolTip = 'Delete the coupling to a Dataverse standard.';                        trigger OnAction()                        var                            ESGStandard: Record "Sust. ESG Standard";                            CRMCouplingManagement: Codeunit "CRM Coupling Management";                            RecRef: RecordRef;                        begin                            CurrPage.SetSelectionFilter(ESGStandard);                            RecRef.GetTable(ESGStandard);                            CRMCouplingManagement.RemoveCoupling(RecRef);                        end;                    }                }                action(ShowLog)                {                    ApplicationArea = Suite;                    Caption = 'Synchronization Log';                    Image = Log;                    ToolTip = 'View integration synchronization jobs for the standard table.';                    trigger OnAction()                    var                        CRMIntegrationManagement: Codeunit "CRM Integration Management";                    begin                        CRMIntegrationManagement.ShowLog(Rec.RecordId);                    end;                }            }        }        area(Promoted)        {            group(Category_Synchronize)            {                Caption = 'Synchronize';                Visible = SustDataverseIntEnabled;                group(Category_Coupling)                {                    Caption = 'Coupling';                    ShowAs = SplitButton;                    actionref(ManageCRMCoupling_Promoted; ManageCRMCoupling)                    {                    }                    actionref(DeleteCRMCoupling_Promoted; DeleteCRMCoupling)                    {                    }                }                actionref(CRMSynchronizeNow_Promoted; CRMSynchronizeNow)                {                }                actionref(ShowLog_Promoted; ShowLog)                {                }            }        }    }    trigger OnOpenPage()    var        SustainabilitySetup: Record "Sustainability Setup";        CRMIntegrationManagement: Codeunit "CRM Integration Management";    begin        CRMIntegrationEnabled := CRMIntegrationManagement.IsCRMIntegrationEnabled();        CDSIntegrationEnabled := CRMIntegrationManagement.IsCDSIntegrationEnabled();        if CRMIntegrationEnabled or CDSIntegrationEnabled then            SustDataverseIntEnabled := SustainabilitySetup.IsDataverseIntegrationEnabled();    end;    trigger OnAfterGetCurrRecord()    var        CRMCouplingManagement: Codeunit "CRM Coupling Management";    begin        if CRMIntegrationEnabled or CDSIntegrationEnabled then            CRMIsCoupledToRecord := CRMCouplingManagement.IsRecordCoupledToCRM(Rec.RecordId);    end;    var        CRMIntegrationEnabled: Boolean;        CDSIntegrationEnabled: Boolean;        CRMIsCoupledToRecord: Boolean;        SustDataverseIntEnabled: Boolean;}