hongji.li
2023-11-07 1a1ba3ad5ed9e4380185aa1ccad20204a0e5f115
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Quintiq file version 2.0
#parent: #root
Method New (
  FormCampaign formCampaign,
  Unit unit,
  CampaignType_MP campaigntype
) id:Method_DialogCreateEditCampaign_New
{
  #keys: '[134266.1.1951136376]'
  Body:
  [*
    // Create a new campaign
    
    // Select an owner
    if( isnull( unit ) )
    {
      unit := select( DataHolderUnit.Data(), Elements, u, u.CampaignType_MP( relsize ) > 0  );
    }
    
    if( isnull( campaigntype ) )
    {
      campaigntype := select( unit, CampaignType_MP, c, true );
    }
    
    campaign := unit.Campaign_MP( relshadow, UnitID := unit.ID(),  CampaignID := "" );// Temporary set CampaignID to empty, will be assigned during OnOK
    
    DataHolderForm.Data( formCampaign );
    
    // Set data to dataholder because Form cannot bind to shadow yet
    DataHolderDialogData.Data( &campaign );
    
    // Set default values from campaign type
    this.SetDefaultValue( campaigntype );
    ApplicationMacroPlanner.ShowFormModal( this );
    
    //Initialize dialog
    Form.InitializeDialog();
    Form.EnableDisableQuantityEditors();
  *]
}