Overview
When you create an object type configuration in M-Files, a default class is automatically created and associated with the new object type. When you import objects from an external database, the imported objects are associated with the object type's default class, unless specified differently.
This article explains what is required to configure the external database connection to import objects to a specific class associated with the object type.
Solution
When importing data to one specific class
When you need to import objects to only one specific class, which is not the object type's default class, you can specify the desired class in the SELECT statement. For example:
SELECT '123' AS MFilesClass, ID, Name from SomeTable
In this example, the MFilesClass column does not exist in the external database, but we use the SELECT statement to set its value to always be 123. In addition to setting the class ID to 123, we also select the ID and Name columns from the external database. Replace 123 with the actual ID of your target class and replace ID and Name with whatever columns you actually need to fetch from the external database.
When importing data to several classes
To import data to variable target classes, the external database must include a column that holds the M-Files ID of the target class. Check the class ID's from M-Files Admin's Class listing.
If you are not allowed to change the actual structure of the external database, which is often the case with databases for third-party systems, consider configuring a view in the external database and using that view as the source table when importing the objects to M-Files.
Once you have the required class IDs as values for some column in the external database, configure the external database connection to map that column to M-Files' Class property.
For general instructions on configuring external database connections, please refer to M-Files user guide.
