Quintiq file version 2.0
#parent: #root
Method ImportData (
  internal[GUIComponent] parent
) id:Method_DialogUserImportProfile_ImportData
{
  #keys: '[132894.0.197566578]'
  Body:
  [*
    // Import data from excel
    // Create an import profile for import purpose
    
    if ( Dialog.DoModal( parent ) > 0 )
    {   
      path := EditorExcelPath.Text();
      Dialog.FormatPath( path );
      
      // Create a profile used to execute import
      data := MPSync.UserImportProfile( relnew,
                                        Name := 'temp',
                                        ExcelPath := path );
      Dialog.Data( data );
      
      try
      {
        Dialog.FindCreateAllImportObjectGroupInProfile();
        
        userimportprofiles := construct( UserImportProfiles );
        userimportprofiles.Add( data );
        Dialog.ExecuteProfiles( userimportprofiles );    
      }
      onerror
      {  
        errormessage := Translations::MPSync_Browser_Import_Excel_Warning();
        MessageBox::Warning( Application, errormessage, 'OK' );
      }
      
      // Delete the profile after executing import
      data.Delete();
    }
  *]
}
