Quintiq file version 2.0
#parent: ListScenario
Response OnClick (
  ScenarioNode selection
) id:Response_ListScenario_MenuFolderNewMacroPlan_OnClick #extension
{
  Body:
  [*
    // To be derived
    
    macroPlanOld := MacroPlan;
    if ( not isnull( macroPlanOld ) ) {
        info( "ListScrnario.MenuFolderNewMacroPlan.OnClick  macroPlanOld : " + [String]macroPlanOld.MDSID() );
    }
    
    // Create a new MP Scenario
    dlg := construct( ScenarioManager_DialogCreateEditMPScenario );
    
    scenario := null( Scenario );
    
    if ( selection.istype( Scenario ) )
    {
      node := selection.Parent();
      scenario := dlg.NewScenario( this, ScenarioManager, node, false );
    }
    else
    {
      scenario := dlg.NewScenario( this, ScenarioManager, selection, false );
    }
    
    if( not isnull( scenario ) )
    {
      ApplicationLibMacroPlanner.AutoExpandSelection( this, scenario );
      ApplicationLibMacroPlanner.SelectScenario( scenario, Form );
      
      // Launch supply chain wizard upon scenario creation
      if( ScenarioManager.LaunchInitializationWizardAtScenarioCreation() )
      {
        ApplicationLibMacroPlanner.LaunchInitializationWizard( MacroPlan );
      }
    }
    
    macroPlanNew := MacroPlan;
    if ( not isnull( macroPlanNew ) ) {
        info( "ListScrnario.MenuFolderNewMacroPlan.OnClick  macroPlanNew : " + [String]macroPlanNew.MDSID() );
    }
    ManufactureLTImputation::Transfer( macroPlanOld, macroPlanNew );
  *]
  Precondition:
  [*
    return not isnull( ScenarioManager ) and selection.CanCreate( feedback, true );
  *]
}
