Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ codeunit 36951 Initialization
DimensionSetEntriesJobQueueDescriptionLbl: Label 'Update Power BI Dimension Set Entries';

procedure SetupDefaultsForPowerBIReportsIfNotInitialized()
var
PBISetup: Record "PowerBI Reports Setup";
begin
InsertGuidedExperience();
InitializePBISetup();
PBISetup.GetOrCreate();
InitializePBIWorkingDays();
InitializeStartingEndingDates();
InitializeDimensionSetEntryCollectionJobQueueEntry();
Expand Down Expand Up @@ -59,16 +61,6 @@ codeunit 36951 Initialization
FinanceInstallationHandler.SetupDefaultsForPowerBIReportsIfNotInitialized();
end;

local procedure InitializePBISetup()
var
PBISetup: Record "PowerBI Reports Setup";
begin
if not PBISetup.Get() then begin
PBISetup.Init();
PBISetup.Insert();
end;
end;

local procedure InitializeStartingEndingDates()
var
AccountingPeriod: Record "Accounting Period";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Microsoft.PowerBIReports;
using System.Environment.Configuration;
using System.Globalization;
using System.Integration.PowerBI;
using System.Utilities;

codeunit 36962 "Power BI Report Setup"
{
Expand All @@ -26,6 +27,47 @@ codeunit 36962 "Power BI Report Setup"
end;
end;

/// <summary>
/// Ensures that everything related to the specified Power BI report setup is properly configured, or directs to the appropriate setup pages. It errors if after the different prompts the report is not set up or in the process of being deployed. Typically used as a validation step before opening an embedded Power BI report page.
/// </summary>
/// <param name="PBIReportSetup">The Power BI report setup to validate.</param>
/// <returns>The GUID of the Power BI report as configured in the setup.</returns>
procedure OpenPowerBIEmbeddedReportPageValidation(PBIReportSetup: Enum "PBI Report Setup"): Guid
var
PowerBIAssistedSetup: Page "PowerBI Assisted Setup";
DeploySelectionPage: Page "PBI Report Deploy. Selection";
ConfiguredReportId: Guid;
ReportNotSetupErr: Label 'Your report has not been setup in PowerBI Reports Setup. You need to set up this report in order to view it.', Comment = '%1 = report name';
begin
EnsureUserAcceptedPowerBITerms();
ConfiguredReportId := GetConfiguredReportId(PBIReportSetup);
if not IsNullGuid(ConfiguredReportId) then
exit(ConfiguredReportId);
PromptOpeningReportDeploymentsWhenInProgress(PBIReportSetup);
if PowerBIAssistedSetup.RunModal() = Action::OK then
if PowerBIAssistedSetup.IsDeployOOBReportsSelected() then
DeploySelectionPage.RunModal();
ConfiguredReportId := GetConfiguredReportId(PBIReportSetup);
if not IsNullGuid(ConfiguredReportId) then
exit(ConfiguredReportId);
PromptOpeningReportDeploymentsWhenInProgress(PBIReportSetup);
Error(ReportNotSetupErr)
end;

local procedure GetConfiguredReportId(PBIReportSetup: Enum "PBI Report Setup"): Guid
var
PowerBIReportsSetup: Record "PowerBI Reports Setup";
RecRef: RecordRef;
ReportSetup: Interface "PBI Report Setup";
ConfiguredReportId: Guid;
begin
PowerBIReportsSetup.GetOrCreate();
RecRef.GetTable(PowerBIReportsSetup);
ReportSetup := PBIReportSetup;
ConfiguredReportId := RecRef.Field(ReportSetup.GetSetupReportIdFieldNo()).Value();
exit(ConfiguredReportId)
end;

procedure GetReportIdAndEnsureSetup(ReportName: Text; FieldId: Integer) ReportId: Guid
var
AssistedSetup: Page "PowerBI Assisted Setup";
Expand All @@ -40,6 +82,47 @@ codeunit 36962 "Power BI Report Setup"
end;
end;

procedure FindReportSetup(DeployableReportType: Enum "Power BI Deployable Report"; var ReportSetup: Interface "PBI Report Setup"): Boolean
var
Ordinal: Integer;
begin
foreach Ordinal in Enum::"PBI Report Setup".Ordinals() do begin
ReportSetup := Enum::"PBI Report Setup".FromInteger(Ordinal);
if ReportSetup.GetDeployableReportType() = DeployableReportType then
exit(true);
end;
Clear(ReportSetup);
exit(false);
end;

local procedure IsReportBeingDeployed(ReportSetup: Interface "PBI Report Setup"): Boolean
var
PowerBIDeployment: Record "Power BI Deployment";
begin
if not PowerBIDeployment.Get(ReportSetup.GetDeployableReportType()) then
exit(false);
PowerBIDeployment.GetUploadStatus();
exit(not (PowerBIDeployment.GetUploadStatus() in [
Enum::"Power BI Upload Status"::Completed,
Enum::"Power BI Upload Status"::Failed,
Enum::"Power BI Upload Status"::Skipped,
Enum::"Power BI Upload Status"::PendingDeletion]));
end;

local procedure PromptOpeningReportDeploymentsWhenInProgress(ReportSetup: Interface "PBI Report Setup"): Boolean
var
ConfirmMgt: Codeunit "Confirm Management";
ReportDeployingQst: Label 'Your %1 report is being deployed to Power BI. Would you like to open the Power BI Report Deployments page to track the status?', Comment = '%1 = report name';
DeployableReport: Interface "Power BI Deployable Report";
begin
DeployableReport := ReportSetup.GetDeployableReportType();
if IsReportBeingDeployed(ReportSetup) then begin
if ConfirmMgt.GetResponse(StrSubstNo(ReportDeployingQst, DeployableReport.GetReportName())) then
Page.Run(Page::"Power BI Report Deployments");
Error('');
end;
end;

local procedure GetReportId(FieldId: Integer): Guid
var
PowerBiReportsSetup: Record "PowerBI Reports Setup";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
namespace Microsoft.PowerBIReports;

using System.Integration.PowerBI;

pageextension 36965 "PBI Report Deployments Ext." extends "Power BI Report Deployments"
{
layout
{
addafter(ReportName)
{
field(SetupConfigured; IsSetupConfigured)
{
ApplicationArea = All;
Caption = 'Linked in Setup';
ToolTip = 'Specifies whether a Power BI report has been configured for this app in the Power BI Reports Setup.';
Editable = false;
}
}
}

actions
{
addlast(NavigateActions)
{
action(OpenPowerBIReportsSetup)
{
ApplicationArea = All;
Caption = 'Power BI Reports Setup';
Image = Setup;
RunObject = page "PowerBI Reports Setup";
ToolTip = 'Opens the Power BI Reports Setup page.';
}
}
addlast(Category_Category2)
{
actionref(PowerBIReportsSetup_Promoted; OpenPowerBIReportsSetup)
{
}
}
}

trigger OnAfterGetRecord()
begin
IsSetupConfigured := GetIsSetupConfigured();
end;

var
IsSetupConfigured: Boolean;

local procedure GetIsSetupConfigured(): Boolean
var
PowerBIReportsSetup: Record "PowerBI Reports Setup";
SetupHelper: Codeunit "Power BI Report Setup";
RecRef: RecordRef;
FldRef: FieldRef;
ReportSetup: Interface "PBI Report Setup";
begin
if not PowerBIReportsSetup.Get() then
exit(false);

if not SetupHelper.FindReportSetup(Rec."Report Id", ReportSetup) then
exit(false);

RecRef.GetTable(PowerBIReportsSetup);
FldRef := RecRef.Field(ReportSetup.GetSetupReportIdFieldNo());
exit(not IsNullGuid(FldRef.Value()));
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,22 @@ page 36950 "PowerBI Assisted Setup"
}

}
group(StepReportChoice)
{
Visible = CurrentStep = Steps::ReportChoice;
group(ReportChoiceIntro)
{
Caption = 'Report Setup';
InstructionalText = 'You can manually configure which Power BI reports to use for each area, or deploy our out-of-the-box reports directly to your Power BI workspace.';
}
field(ReportSetupChoice; ReportSetupChoice)
{
ApplicationArea = All;
Caption = 'I would like to';
ToolTip = 'Specifies whether to manually configure report settings or deploy pre-built reports.';
OptionCaption = 'Deploy out-of-the-box reports,Configure report settings';
}
}
group(Step5)
{
Visible = CurrentStep = Steps::Setting;
Expand Down Expand Up @@ -760,6 +776,11 @@ page 36950 "PowerBI Assisted Setup"

trigger OnAction()
begin
if (CurrentStep = Steps::ReportChoice) and (ReportSetupChoice = ReportSetupChoice::"Deploy out-of-the-box reports") then begin
GuidedExperience.CompleteAssistedSetup(ObjectType::Page, Page::"PowerBI Assisted Setup");
CurrPage.Close();
exit;
end;
TakeStep(1);
end;
}
Expand Down Expand Up @@ -789,7 +810,7 @@ page 36950 "PowerBI Assisted Setup"
TimeZoneSelection: Codeunit "Time Zone Selection";
EnvironmentInformation: Codeunit "Environment Information";
SetupHelper: Codeunit "Power BI Report Setup";
Steps: Option Intro,DateTableConfig,UTCOffset,WorkingDays,Setting,Finish;
Steps: Option Intro,DateTableConfig,UTCOffset,WorkingDays,ReportChoice,Setting,Finish;
PrevStep: Option;
CurrentStep: Option;
BackEnabled: Boolean;
Expand All @@ -815,10 +836,13 @@ page 36950 "PowerBI Assisted Setup"
ShowLessTxt: Label 'Show Less';
AdminPermissionRequiredErr: Label 'Setting up Power BI requires the ''%1'' permission set (or equivalent) that your account doesn''t have. Ask your administrator to assign the permission set to you.', Comment = '%1 = permission set name';
PermisionSetNameTok: Label 'Power BI Core Admin', Locked = true;
IsEvalCompany: Boolean;
ReportSetupChoice: Option "Deploy out-of-the-box reports","Configure report settings";

trigger OnOpenPage()
var
UserSetup: Record "User Setup";
CurrentCompany: Record Company;
PowerBIReportsSetup: Record "PowerBI Reports Setup";
begin
if not PowerBIReportsSetup.WritePermission() then
Expand All @@ -830,6 +854,9 @@ page 36950 "PowerBI Assisted Setup"
if NavApp.GetCurrentModuleInfo(AppInfo) then
AssistedSetupComplete := GuidedExperience.IsAssistedSetupComplete(ObjectType::Page, Page::"PowerBI Assisted Setup");

CurrentCompany.Get(CompanyName());
IsEvalCompany := CurrentCompany."Evaluation Company";

if UserSetup.Get(UserId()) then
TestEmailAddress := UserSetup."E-Mail";

Expand All @@ -855,6 +882,11 @@ page 36950 "PowerBI Assisted Setup"

PrevStep := CurrentStep;
CurrentStep := CurrentStep + Step;

// Skip ReportChoice for non-evaluation companies
if (CurrentStep = Steps::ReportChoice) and (not IsEvalCompany) then
CurrentStep := CurrentStep + Step;

NextEnabled := false;
BackEnabled := true;
FinishEnabled := false;
Expand All @@ -869,13 +901,12 @@ page 36950 "PowerBI Assisted Setup"
if CalendarType > 0 then
NextEnabled := true;
Steps::UTCOffset:

NextEnabled := true;
Steps::WorkingDays:

NextEnabled := true;
Steps::ReportChoice:
NextEnabled := true;
Steps::Setting:

NextEnabled := true;
Steps::Finish:
begin
Expand Down Expand Up @@ -929,4 +960,9 @@ page 36950 "PowerBI Assisted Setup"
end;
end;
end;

procedure IsDeployOOBReportsSelected(): Boolean
begin
exit(IsEvalCompany and (ReportSetupChoice = ReportSetupChoice::"Deploy out-of-the-box reports"));
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ using System.Integration.PowerBI;

page 36963 "Power BI Selection Lookup"
{
ApplicationArea = All;
Caption = 'Select Power BI Element';
DeleteAllowed = false;
InsertAllowed = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ permissionset 36951 "PowerBi Report Basic"
page "Working Days" = X,
page "Working Days Setup" = X,
page "Working Days Subform" = X,
page "PBI Report Deploy. Selection" = X,
page "Account Categories" = X,
query "Account Categories" = X,
query "Resources - PBI API" = X,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace Microsoft.PowerBIReports;
using System.Integration.PowerBI;

enumextension 36950 "Power BI Deployable Report" extends "Power BI Deployable Report"
{
value(36950; "Finance App")
{
Caption = 'Finance';
Implementation = "Power BI Deployable Report" = "PBI Finance App";
}
value(36951; "Sales App")
{
Caption = 'Sales';
Implementation = "Power BI Deployable Report" = "PBI Sales App";
}
value(36952; "Purchases App")
{
Caption = 'Purchases';
Implementation = "Power BI Deployable Report" = "PBI Purchases App";
}
value(36953; "Inventory App")
{
Caption = 'Inventory';
Implementation = "Power BI Deployable Report" = "PBI Inventory App";
}
value(36954; "Inventory Valuation App")
{
Caption = 'Inventory Valuation';
Implementation = "Power BI Deployable Report" = "PBI Inventory Val. App";
}
value(36955; "Manufacturing App")
{
Caption = 'Manufacturing';
Implementation = "Power BI Deployable Report" = "PBI Manufacturing App";
}
value(36956; "Projects App")
{
Caption = 'Projects';
Implementation = "Power BI Deployable Report" = "PBI Projects App";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Microsoft.PowerBIReports;
using System.Integration.PowerBI;

codeunit 36959 "Power BI Subscribers"
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"PBI Deployment Events", OnReportDeployed, '', false, false)]
local procedure OnReportDeployed(var Report: Interface "Power BI Uploadable Report"; DeployableReportType: Enum "Power BI Deployable Report")
var
PowerBIReportsSetup: Record "PowerBI Reports Setup";
SetupHelper: Codeunit "Power BI Report Setup";
RecRef: RecordRef;
UploadTracker: Interface "Power BI Upload Tracker";
ReportSetup: Interface "PBI Report Setup";
ReportName: Text[200];
begin
if not SetupHelper.FindReportSetup(DeployableReportType, ReportSetup) then
exit;

Report.GetUploadTracker(UploadTracker);
UploadTracker.Load(Report.GetReportKey());
ReportName := CopyStr(UploadTracker.GetUploadedReportName(), 1, MaxStrLen(ReportName));

PowerBIReportsSetup.GetOrCreate();
RecRef.GetTable(PowerBIReportsSetup);
RecRef.Field(ReportSetup.GetSetupReportIdFieldNo()).Value := UploadTracker.GetUploadedReportId();
RecRef.Field(ReportSetup.GetSetupReportNameFieldNo()).Value := ReportName;
RecRef.Modify();
end;
}
Loading
Loading