| Quintiq file version 2.0 | 
| #parent: #root | 
| Method InitializeDataHolder ( | 
|   structured[UnitPeriodTime] selection | 
| ) id:Method_DialogCreateEditUnitAvailability_InitializeDataHolder | 
| { | 
|   #keys: '[151892.0.49084539]' | 
|   Body: | 
|   [* | 
|     //Initial dataholder | 
|      | 
|     DataHolderUnitPeriodTime.Data( selection.Copy() ); | 
|      | 
|     // Get the shift patterns that are allowed on every selected unit. | 
|     shiftpatterns := ShiftPattern::GetAvailableShiftPatterns( MacroPlan, selection ); | 
|     DataHolderShiftPattern.Data( &shiftpatterns ); | 
|      | 
|     firstElement := minselect( selection, Elements, e, true, e.Start() ); | 
|      | 
|     // Need this for excluding itself in pre-condition primary keys checking. | 
|     data := shadow( firstElement.UnitAvailability() ); | 
|      | 
|     // In case selection.Element( 0 ) doesn't bind to any unit availability, calling SetDefaultValue method will return null error. | 
|     // Check start in case of editing from UPT later than the existing UA, the Start date will be off if we pass in existing UA | 
|     if( isnull( data ) | 
|         or data.Start() <> firstElement.Start() ) | 
|     { | 
|       data := firstElement.Unit().UnitAvailability( relshadow, UnitID := firstElement.Unit().ID(), Start := firstElement.Start() ); | 
|     } | 
|      | 
|     DataHolderDialogData.Data( &data ); | 
|     Form.SetDefaultValue( firstElement ); | 
|     ApplicationMacroPlanner.ShowFormModal( this ); | 
|   *] | 
| } |