Quintiq file version 2.0 
 | 
#parent: #root 
 | 
StaticMethod ValidateInput ( 
 | 
  output String feedback_o, 
 | 
  Unit unit, 
 | 
  String name, 
 | 
  Real minquantity, 
 | 
  Real maxquantity, 
 | 
  CampaignType_MP campaigntype, 
 | 
  Boolean checkunique 
 | 
) declarative remote as Boolean 
 | 
{ 
 | 
  Description: 'Checks the correctness of input data from Create/Edit dialog.' 
 | 
  TextBody: 
 | 
  [* 
 | 
    feedback_o := ''; 
 | 
     
 | 
    // Length limit of name 
 | 
    lengthlimit := GlobalParameters_MP::GetLengthOfNames(); 
 | 
     
 | 
    // Check if unit is null 
 | 
    if( isnull( unit ) ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_CampaignType_ValidateInput_IsNullUnit() ; 
 | 
    } 
 | 
    // Check if name is unique 
 | 
    else if( checkunique 
 | 
             and exists( unit, CampaignType_MP, ct, 
 | 
                         ct <> campaigntype, 
 | 
                         ct.Name() = name ) ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_CampaignType_ViolateHasUniqueName(); 
 | 
    } 
 | 
    // Check if name is valid 
 | 
    else if( name = '' or  name.Length() > lengthlimit ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_CampaignType_ValidateInput_IsNameEmptyOrExceedLengthLimit( lengthlimit ); 
 | 
    } 
 | 
    // Check if min quantity is valid 
 | 
    else if( minquantity < 0 ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_CampaignType_ValidateInput_IsNegativeMinQuantity( minquantity ); 
 | 
    } 
 | 
    // Check if max quantity is valid 
 | 
    else if( maxquantity < 0 ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_CampaignType_ValidateInput_IsNegativeMaxQuantity( maxquantity ); 
 | 
    } 
 | 
    // Check if min & max quantity combination is valid 
 | 
    else if( maxquantity < minquantity ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_CampaignType_ValidateInput_IsMinQuantityLessThanMaxQuantity( minquantity, maxquantity ); 
 | 
    } 
 | 
     
 | 
    // Add feedback text if any precondition above is violated 
 | 
    if( feedback_o <> '' ) 
 | 
    { 
 | 
      subname := MacroPlan::GetSubstituteName( name ); 
 | 
      feedback_o := SanityCheckMessage::GetFormattedMessage( Translations::MP_CampaignType_Instance( subname ), 
 | 
                                                             feedback_o ); 
 | 
    } 
 | 
     
 | 
    return feedback_o.Length() = 0 
 | 
  *] 
 | 
} 
 |