Quintiq file version 2.0
#parent: #root
Method GetDefaultCampaignTypeName (
  String defaultCampaignName,
  Unit unit
) as String id:Method_DialogCreateEditCampaignType_GetDefaultCampaignTypeName
{
  #keys: '[150660.1.855728444]'
  Body:
  [*
    // Case 0: No campaign type exist, default name = unit name
    // Case 1: Has campaign type with unit name, default name = unit name + (1)
    // Case 2: Has campaign type with unit name (1), default name = unit name (1) + (1)
    // Recursively append (1) to campaign type name if dropped unit has already created a campaign type
    return ifexpr( isnull( MacroPlan.GetCampaignType( defaultCampaignName, guard( unit.ID(), '' ) ) ), 
                   defaultCampaignName, 
                   this.GetDefaultCampaignTypeName( defaultCampaignName + '(1)', unit ) );
  *]
}
