| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod ValidateInput ( | 
|   output String feedback_o, | 
|   output String sanitycheckfeedback_o, | 
|   MacroPlan macroplan, | 
|   CampaignType_MP campaigntype, | 
|   DateTime start, | 
|   DateTime end, | 
|   Real minqty, | 
|   Real maxqty, | 
|   String comment, | 
|   Campaign_MP_DELETED_Q320 campaign, | 
|   Boolean checkunique | 
| ) declarative remote as Boolean | 
| { | 
|   Description: 'Checks the correctness of input data from Create/Edit dialog.' | 
|   TextBody: | 
|   [* | 
|     // Precondition to validate the input for creating/editing Campaign_MP | 
|     feedback_o := ''; | 
|     sanitycheckfeedback_o := ''; | 
|      | 
|     // Check if campaign type is null | 
|     if( isnull( campaigntype ) ) | 
|     { | 
|       feedback_o := Translations::MP_Campaign_ValidateInput_IsNullCampaignType(); | 
|       sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // Check if start and end time window is valid | 
|     else if( start >= end ) | 
|     { | 
|       feedback_o := '' // Translation is removed as object not in-used anymore | 
|       sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // Check if minimum quantity is valid | 
|     else if( minqty < 0 ) | 
|     { | 
|       feedback_o := Translations::MP_Campaign_ValidateInput_IsNegativeMinQuantity( minqty ); | 
|       sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // Check if maximum quantity is valid | 
|     else if( maxqty < 0 ) | 
|     { | 
|       feedback_o := Translations::MP_Campaign_ValidateInput_IsNegativeMaxQuantity( maxqty ); | 
|       sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // Check if maximum quantity is larger than minimum quantity | 
|     else if( maxqty < minqty ) | 
|     { | 
|       feedback_o := Translations::MP_Campaign_ValidateInput_IsMaxQuantityLessThanMaxQuantity( minqty, maxqty ); | 
|       sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // Check if campaign details are unique | 
|     else if( checkunique | 
|              and exists( campaigntype, Unit.Campaign_MP_DELETED_Q320, cpg, | 
|                          cpg <> campaign | 
|                          and Period_MP::IsInPeriod( start, end, cpg.Start(), cpg.End() ) ) ) | 
|     { | 
|       feedback_o := Translations::MP_Campaign_ViolatesIsPlannedWithNoOverlap(); | 
|       sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|      | 
|     // Format feedback text if any of the precondition above is violated | 
|     if( feedback_o <> '' ) | 
|     { | 
|       instance := Campaign_MP_DELETED_Q320::GetInstanceText( campaigntype, start ); | 
|       feedback_o := SanityCheckMessage::GetFormattedMessage( instance, feedback_o ); | 
|     } | 
|      | 
|     return feedback_o.Length() = 0 | 
|   *] | 
| } |