Quintiq file version 2.0
#parent: #root
Method NewOperation (
  internal[GUIComponent] parent,
  Unit owner,
  RoutingStep routingstep
) as Operation id:Method_DialogCreateEditOperation_NewOperation
{
  #keys: '[109478.0.546849391]'
  Body:
  [*
    // Create operation
    operationinrs := routingstep.Operation( relsize );
    units := MacroPlan.Unit( relsize );
    
    // Select any unit if the selected unit is null
    if( isnull( owner ) )
    {
      owner := Operation::GetDefaultOwner( MacroPlan, routingstep );
    }
    
    operationid := Operation::GetConcatenatedID( routingstep.RoutingID(),
                                                 routingstep.Name(),
                                                 ifexpr( operationinrs < units, guard( owner.ID(), '' ), '' ) );
    
    
    data := owner.Operation( relshadow,
                             Operation,
                             ID := operationid,
                             RoutingStepName := routingstep.Name(),
                             RoutingID := routingstep.Routing().ID() );
    
    Dialog.Data( data );
    
    //moved here, dialog.data is referenced in this method
    Dialog.ShowHideComponentForBatchEdit( false );
    Dialog.SetTooltips();
    
    result := this.DoModal( parent );
    
    if ( result > 0 )
    {
      data.Commit();
    }
    
    return data.WrappedInstance();
  *]
}
