Quintiq file version 2.0
#parent: #root
Method OnOK () id:Method_DialogCreateEditUOM_OnOK
{
  #keys: '[139394.0.551292325]'
  Body:
  [*
    // On ok
    Form.ApplyChanges();
    
    data := DataHolderDialogData.Data();
    if( isnull(  data.WrappedInstance() ) )
    {
      newUOM :=    UnitOfMeasure_MP::CreateWithConversionFactorToBaseUOM( MacroPlan, 
                                                                          EditFieldName.Text(),
                                                                          ConversionFactor::GetReverseFactor( ApplicationMacroPlanner.FormatStringToReal( EditFieldFactor.Text() ) ),
                                                                          false,
                                                                          false /*isfromdb*/ );
      // Access the form, select the new UOM
      DataHolderForm.Data().ListUOM().SelectByKey( newUOM.Key() );
    
    }
    else
    {
      data.WrappedInstance().Update( EditFieldName.Text(),
                                     MacroPlan.DefaultUnitOfMeasure(),
                                     ConversionFactor::GetReverseFactor( ApplicationMacroPlanner.FormatStringToReal( EditFieldFactor.Text() ) ),
                                     data.WrappedInstance().IsDefault(),
                                     false /*isfromdb*/
                                   )
    }
    
    Form.Close();
  *]
}
