Quintiq file version 2.0
#parent: #root
Method CreateCampaignAndResequence (
  internal[GUIComponent] parent,
  CampaignType_MP campaigntype,
  Unit owner,
  Campaign_MP targetcampaign,
  Transition_MP transition,
  DateTime droptime
) as Campaign_MP id:Method_DialogCreateEditCampaign_MP_CreateCampaignAndResequence
{
  #keys: '[149260.0.934786925]'
  Accessibility: 'Extensible'
  Body:
  [*
    // New campaign
    
    if( isnull( campaigntype ) )
    {
      campaigntype := Campaign_MP::GetDefaultCampaignType( owner );
    }
    
    data := owner.Campaign_MP( relshadow, UnitID := owner.ID(), 
                                          InputType := campaigntype.InputType(),
                                          CampaignID := "" );// Temporary set CampaignID to empty, will be set during campaign creation
    Dialog.Data( data ); 
    Dialog.SetDefaultValue( campaigntype );
    Dialog.InitializeDialog();
    this.SetIndicatorValue();
    
    result := Dialog.DoModal( parent );
    newobj := null( Campaign_MP );
    
    if( result > 0 )
    {
      campaignid := OS::GenerateGUIDAsString();
      newobj := Campaign_MP::CreateAndResequence( owner,
                                                  data.EarliestStart(),
                                                  data.SequenceNumberForExcel(),
                                                  data.MinQuantity(),
                                                  data.MaxQuantity(),
                                                  data.MinDuration(),
                                                  data.MaxDuration(),
                                                  SelectionCampaignType.Data().Name(),
                                                  campaignid,
                                                  data.Comment(),
                                                  data.HasInputMaxQuantity() and RadioButtonGroupQuantityDuration.BoundValue() = GlobalParameters_MP::GetCampaignTransitionsTypeQuantity(),
                                                  data.HasInputMaxDuration() and RadioButtonGroupQuantityDuration.BoundValue() = GlobalParameters_MP::GetCampaignTransitionsTypeDuration(),
                                                  false,
                                                  targetcampaign,
                                                  transition,
                                                  droptime);
    }
    return newobj;
  *]
  UseInheritedAccessibility: false
}
