Quintiq file version 2.0
#parent: #root
Method InitializeDataHolders (
  Boolean ishome
) id:Method_ApplicationMacroPlanner_InitializeDataHolders
{
  #keys: '[138546.0.807200038]'
  Body:
  [*
    // Reset nav panel selection
    // Switching scenario now clear selection, this will affect DHActiveScenario.OnDataChanged & Sales > Sales Segment button.OnClick
    this.ClearNavigationPanelDataHolder();
    
    if( not isnull( ScenarioManager ) and not isnull( MacroPlan ) )
    {
      // Set dropdown to the active scenario
      activescenario := select( ScenarioManager, ScenarioMP, sce, sce.DatasetMDSID() = MacroPlan.MDSID() );
      DropDownListScenario.Data( activescenario );  
      
      if( not ishome )  // Accounts initialization should not be triggered during navigation panel home
      {
        // Select inventory holding cost account by default
        accounts := selectsortedset( MacroPlan, Account_MP, acc, acc.IsForAccountAssignment() and acc.Value() > 0, acc.Name() );
        periodspec := select( MacroPlan, PeriodSpecification_MP, pspec, pspec.IsDummyPlanningPeriod() );
        if( accounts.Size() > 0 )
        {
          DataHolderScenarioAnalysisAccount.Data( accounts.Element( 0 ) );
          DataHolderScenarioComparisonAccount.Data( accounts.Element( 0 ) );  
        }
        DataHolderPeriodSpec.Data( periodspec );
        // Don't auto select scenario if we home
        DataHolderFocusedScenario.Data().Flush();
        DataHolderFocusedScenario.Data().Add( activescenario );
      }
    }
    
    // Update to the user specific view
    ApplicationMacroPlanner.SupplyChainDiagramSetSupplyChainView( MacroPlan );
  *]
}
