In this article we will be using an Excel file (.csv) to import a list of employees into M-Files.
To do this we have created an object type in M-Files called Employees.
Below we will be setting up the data source and the external object connection for the Employee object type.
1) Take the CSV file you wish to use as a data source and place it on the M-Files Server machine or another accessible location on your network.
2) Create the ODBC Data Source.
- Open ODBC Data Source Administrator (64-bit).
- Select the 'System DSN' tab > Add.
- Select the 'Microsoft Access Text Driver (*.txt, *.csv)' driver > Finish.
- Enter a name for the ODBC source (e.g. Employees), uncheck 'Use Current Directory', select the appropriate directory > OK.
4) Create the Employee object and configure the connection string.
- Open M-Files Admin and create a new object (e.g. Employee). Add the properties to the Employee class that you wish to map to the columns in your .csv.
*Be sure to disable the setting 'Users can create objects of this type' in the 'General' tab.
- Open the new Employee object properties and select the 'Connections to External Database' tab.
- Check 'Use a connection to an external database...' option and click 'Define' for the OLE DB connection string.
- Select the 'Microsoft OLE DB Provider for ODBC Drivers' option in the 'Provider' tab > Next.
- In the 'Connection' tab, select the data source we created in step 2 from the 'Use data source name' drop-down (e.g.Employees).
- Enter any credential information as well if necessary (i.e. accessing a network drive).
- Select the appropriate initial catalog (e.g. the file path to the .csv file).
- Test Connection to make sure all of the above steps were completed successfully > OK.
5) Configure the SELECT statement and map source columns to the target properties.
- To select the data from the .csv > SELECT * FROM <filename>.csv.
- Click 'Refresh Columns'. This will execute the query and display the columns from the .csv.
- Map the 'Source Columns' from the .csv to the correct properties in M-Files for the Employee class ('Target Property').
For example, ID = Object ID, NAME = Name or Title, etc..
- Once the properties are mapped, click Apply > OK. You can now log into the desktop client and search for the Employee objects to confirm that everything appears as expected.
If you have any questions or experience any issues, please contact M-Files Support at email@example.com for assistance.