| Quintiq file version 2.0 | 
| #parent: #root | 
| Method MPSyncCampaignType_MP ( | 
|   Boolean isoverwritemanualconfig, | 
|   IOCampaignType_MPs iocampaigntype_mps | 
| ) | 
| { | 
|   Description: 'Synchronization of CampaignType_MP for MPSync' | 
|   TextBody: | 
|   [* | 
|     // Select a set of existing CampaignType_MP | 
|     existing := selectset( this, Unit.CampaignType_MP, item, true ); | 
|     updates := construct( CampaignType_MPs ); | 
|      | 
|     // Traverse the new set of valid CampaignType_MP | 
|     traverse( iocampaigntype_mps , Elements, io, io.IsValid() ) | 
|     { | 
|       name := io.Name(); | 
|       unitid := io.UnitID(); | 
|       // Find existing CampaignType_MP | 
|       objectinstance := CampaignType_MP::FindCampaignTypeTypeIndex( name, unitid ); | 
|       // Find existing Unit | 
|       unit := Unit::FindUnitTypeIndex( unitid ); | 
|       // If no existing CampaignType_MP is found, and a valid Unit is found, create one | 
|       if( isnull( objectinstance ) ) | 
|       { | 
|         if( not isnull( unit ) ) | 
|         { | 
|               objectinstance := CampaignType_MP::Create( unit, | 
|                                                          name, | 
|                                                          io.DefaultMinQuantity(), | 
|                                                          io.DefaultMaxQuantity(), | 
|                                                          io.DefaultMinDuration(), | 
|                                                          io.DefaultMaxDuration(), | 
|                                                          io.Color(), | 
|                                                          io.HasInputMaxQuantity(), | 
|                                                          io.HasInputMaxDuration(), | 
|                                                          true );  | 
|             | 
|                                                       | 
|         } | 
|       } | 
|       // Else if the CampaignType_MP is not manually configured or the imported instance should overwrite manual configuration, | 
|       // update the existing CampaignType_MP | 
|       else if( not objectinstance.IsManuallyConfigured() or isoverwritemanualconfig ) | 
|       { | 
|         // Update CampaignType_MP | 
|         if( not isnull( unit ) ) | 
|         { | 
|           objectinstance.Update( unit, | 
|                                  io.Name(), | 
|                                  CampaignType_MP::GetInputType( io.DefaultMinQuantity(), io.HasInputMaxQuantity(), io.DefaultMinDuration(), io.HasInputMaxDuration() ), | 
|                                  io.DefaultMinQuantity(), | 
|                                  io.DefaultMaxQuantity(), | 
|                                  io.DefaultMinDuration(), | 
|                                  io.DefaultMaxDuration(), | 
|                                  io.Color(), | 
|                                  io.HasInputMaxQuantity(), | 
|                                  io.HasInputMaxDuration(), | 
|                                  true ); | 
|           updates.Add( objectinstance ); | 
|         } | 
|       } | 
|       if( not isnull( objectinstance ) ) | 
|       { | 
|         objectinstance.CustomUpdate( io, isoverwritemanualconfig );   | 
|       } | 
|     } | 
|      | 
|     // Get the set of old CampaignType_MP to be deleted | 
|     tobedeleteset := existing.Difference( updates ); | 
|      | 
|     // Traverse the set of CampaignType_MP to be deleted | 
|     // Only delete CampaignType_MP that is not manually configured or the imported instance should overwrite manual configuration | 
|     traverse( tobedeleteset, Elements, ele, | 
|               not ele.IsManuallyConfigured() or isoverwritemanualconfig ) | 
|     { | 
|       ele.Delete(); | 
|     } | 
|   *] | 
| } |