OBJECT Page 1853 Sales Inventory Forecast Setup
{
  OBJECT-PROPERTIES
  {
    Date=;
    Time=;
    Version List=;
  }
  PROPERTIES
  {
    CaptionML=ENU=Sales & Inventory Forecast Setup;
    InsertAllowed=No;
    DeleteAllowed=No;
    SourceTable=Table1853;
    PageType=Card;
    ShowFilter=No;
    OnOpenPage=VAR
                 ItemSalesForecastScheduler@1000 : Codeunit 1852;
                 AzureKeyVaultManagement@1001 : Codeunit 2200;
               BEGIN
                 IF ItemSalesForecastScheduler.JobQueueEntryCreationInProcess THEN
                   ERROR(JobQueueCreationInProgressErr);
                 GetSingleInstance(AzureKeyVaultManagement);
                 APIKey := GetAPIKey;
               END;

    ActionList=ACTIONS
    {
      { 11      ;    ;ActionContainer;
                      ActionContainerType=ActionItems }
      { 12      ;1   ;Action    ;
                      Name=Setup Scheduled Forecasting;
                      CaptionML=ENU=Setup Scheduled Forecasting;
                      ToolTipML=ENU=Setup scheduled forecasting of item sales;
                      ApplicationArea=#Basic,#Suite;
                      Promoted=Yes;
                      PromotedIsBig=Yes;
                      Image=Calendar;
                      PromotedOnly=Yes;
                      OnAction=VAR
                                 ItemSalesForecastScheduler@1000 : Codeunit 1852;
                               BEGIN
                                 CheckURIAndKey;
                                 ItemSalesForecastScheduler.CreateJobQueueEntryAndOpenCard;
                               END;
                                }
      { 14      ;1   ;Action    ;
                      Name=Update Forecast;
                      CaptionML=ENU=Update Forecast;
                      ToolTipML=ENU=Update forecast for all items;
                      ApplicationArea=#Basic,#Suite;
                      Promoted=Yes;
                      PromotedIsBig=Yes;
                      Image=Campaign;
                      PromotedOnly=Yes;
                      OnAction=VAR
                                 JobQueueEntry@1001 : Record 472;
                                 ItemSalesForecastScheduler@1000 : Codeunit 1852;
                               BEGIN
                                 CheckURIAndKey;
                                 ItemSalesForecastScheduler.CreateJobQueueEntry(JobQueueEntry,FALSE);
                                 CODEUNIT.RUN(CODEUNIT::"Job Queue - Enqueue",JobQueueEntry);
                                 MESSAGE(UpdatingForecastsMsg);
                               END;
                                }
      { 19      ;1   ;Action    ;
                      Name=Open Cortana Intelligence Gallery;
                      CaptionML=ENU=Open Cortana Intelligence Gallery;
                      ToolTipML=ENU=Explore models for Azure Machine Learning, and use Azure Machine Learning Studio to build, test, and deploy the Forecasting Model for Microsoft Dynamics 365 for Financials.;
                      ApplicationArea=#Basic,#Suite;
                      Promoted=Yes;
                      Image=LinkWeb;
                      OnAction=BEGIN
                                 HYPERLINK('https://go.microsoft.com/fwlink/?linkid=828352');
                               END;

                      Gesture=None }
    }
  }
  CONTROLS
  {
    { 1   ;0   ;Container ;
                ContainerType=ContentArea }

    { 2   ;1   ;Group     ;
                CaptionML=ENU=General;
                GroupType=Group }

    { 3   ;2   ;Field     ;
                ToolTipML=ENU=Specifies the type of period that you want to see the forecast by.;
                ApplicationArea=#Basic,#Suite;
                SourceExpr="Period Type" }

    { 4   ;2   ;Field     ;
                ToolTipML=ENU=Specifies how many periods you want the forecast to cover.;
                ApplicationArea=#Basic,#Suite;
                SourceExpr=Horizon }

    { 15  ;2   ;Field     ;
                ToolTipML=ENU=Specifies when you want to be warned about predicted stockout.;
                ApplicationArea=#Basic,#Suite;
                SourceExpr="Stockout Warning Horizon";
                Importance=Additional }

    { 5   ;2   ;Field     ;
                ToolTipML=ENU=Specifies the API URI to the AzureML instance.;
                ApplicationArea=#Basic,#Suite;
                SourceExpr="API URI" }

    { 6   ;2   ;Field     ;
                Name=APIKey;
                ExtendedDatatype=Masked;
                CaptionML=ENU=API Key;
                ToolTipML=ENU=Specifies the API Key to the AzureML time series experiment.;
                ApplicationArea=#Basic,#Suite;
                SourceExpr=APIKey;
                OnValidate=BEGIN
                             SetUserDefinedAPIKey(APIKey);
                           END;

                OnDrillDown=BEGIN
                              IF NOT ISNULLGUID("API Key ID") THEN
                                MESSAGE(GetUserDefinedAPIKey);
                            END;
                             }

    { 7   ;2   ;Field     ;
                ToolTipML=ENU=Specifies the number of seconds to wait before the call to AzureML times out.;
                ApplicationArea=#Basic,#Suite;
                SourceExpr="Timeout (seconds)";
                Importance=Additional }

    { 8   ;2   ;Field     ;
                ToolTipML=ENU=Specifies the deviation level  for the forecast that you accept. The maximum Variance % that you can allow is 100.;
                ApplicationArea=#Basic,#Suite;
                SourceExpr="Variance %";
                Importance=Additional }

    { 9   ;2   ;Field     ;
                ToolTipML=ENU=Specifies the number of days until the forecast expires.;
                ApplicationArea=#Basic,#Suite;
                SourceExpr="Expiration Period (Days)";
                Importance=Additional }

    { 10  ;2   ;Field     ;
                ToolTipML=ENU=Specifies the number of historical periods to include in the forecast.;
                ApplicationArea=#Basic,#Suite;
                SourceExpr="Historical Periods";
                Importance=Additional }

    { 16  ;1   ;Group     ;
                CaptionML=ENU=Statistics;
                GroupType=Group }

    { 13  ;2   ;Field     ;
                ToolTipML=ENU=Specifies the date and time of the last completed forecast update. The field is not editable.;
                ApplicationArea=#Basic,#Suite;
                SourceExpr="Last Run Completed" }

    { 17  ;2   ;Field     ;
                Name=Used Processing Time (Seconds);
                CaptionML=ENU=Used Processing Time (Seconds);
                ToolTipML=ENU=Specifies the used processing time in seconds. The field is not editable.;
                ApplicationArea=#Basic,#Suite;
                SourceExpr=GetMLTotalProcessingTime }

  }
  CODE
  {
    VAR
      UpdatingForecastsMsg@1001 : TextConst 'ENU=Sales forecasts are being updated in the background. It may take a few moments, before the updated forecasts are available.';
      APIKey@1000 : Text[250];
      JobQueueCreationInProgressErr@1003 : TextConst 'ENU=The process of scheduling sales forecast is in progress. Please wait while the operation is being completed.';

    LOCAL PROCEDURE GetMLTotalProcessingTime@1() : Decimal;
    VAR
      AzureMachineLearningUsage@1000 : Record 2002;
    BEGIN
      AzureMachineLearningUsage.GetSingleInstance;
      EXIT(ROUND(AzureMachineLearningUsage.GetTotalProcessingTime,1));
    END;

    BEGIN
    END.
  }
}

