🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Import Data
This page was created by Alexandra on 2017-05-19. Last edited by Wikiadmin on 2026-07-29.

You can create and update model objects from tab-separated data, such as rows copied from Excel, by configuring a ViewModel seeker import.

Use the current ViewModel import workflow

This page replaces the former EcoSpaceDebugger-specific import description. The current import behavior is part of ViewModel SeekLogic, so the same configured import can work in Turnkey, VMClass, code-generated ViewModels, WPF, the debugger, and server-side ViewModels in MDrivenServer.

Use this approach when you have tab-separated rows and want the first value in each row to identify an existing object or create a new one. For example, you can paste the following rows from Excel to update objects identified by Guid:

793e00a1-7e61-4261-a2ed-7e9047e2c5c4    My new value 1
6d47193c-e4b9-486b-827d-104e01466a81    My new value 2

The first column identifies the object. The remaining columns supply values for the editable result-grid columns.

Configure an import seeker

  1. Create a seeker ViewModel for the class that you want to import.
  2. Make the default search field multi-line. The search field is normally backed by vSeekParam; multi-line input allows pasted tab characters and multiple rows.
  3. Configure the seeker criteria to find an object from the first imported column. For example, a seeker may search Thing.Guid.
  4. Add the columns that the import must write to the search-result grid.
  5. Make each column that must receive imported data editable. Read-only columns are skipped by the seeker import logic.
  6. If missing keys must create objects, add a ViewModel action named CreateNew. That action must create an object of the seeker class.

When users paste data into the multi-line search field and execute the search, the seeker processes each row. It uses the first column as the key, finds or creates an object, and writes values to the editable columns.

How keys, updates, and creation work

The first tab-separated column is always the key. The seeker uses its own search criteria to find an object for that key.

Import result Behavior
A matching object is found The import writes the remaining column values to that object’s editable result-grid columns.
No matching object is found and CreateNew exists The import executes CreateNew, adds the new object to the search result, and writes the imported values.
No matching object is found and CreateNew does not exist The row cannot create a target object through this mechanism.
A target column is read-only The import skips that column.

For example, assume the seeker finds Thing objects by Guid and exposes an editable Name column. Pasting this row updates the matching object:

793e00a1-7e61-4261-a2ed-7e9047e2c5c4    My new value 1

If the Guid does not exist and CreateNew creates a Thing, the same row creates a new Thing and assigns its imported value.

Use non-string keys

The pasted key starts as text. When your seeker uses Guid or Integer keys, define the corresponding optional variable so the search can use the correctly typed value.

Variable Type When it is populated
vSeekParam String Standard seeker parameter; contains the imported key text.
vSeekParamAsGuid Guid Populated before search when it exists and the imported key can be parsed as a Guid.
vSeekParamAsInt Integer Populated before search when it exists and the imported key can be parsed as an Integer.

For a Guid-based seeker, define vSeekParamAsGuid : Guid and use that typed value in the seeker criteria. This avoids comparing a string search parameter to a Guid in the translated query.

Import values and single links

Each imported field maps to a result-grid column. Editable value columns receive the pasted value. A column presented as a combobox can string-match an imported value and set the corresponding single link.

For example, an import row can contain a product key followed by a category name:

P-100    Hardware

If the first column finds the product and the Category result column is an editable combobox, the import can use the text Hardware to select the matching linked category.

Design the seeker and its result columns to make the imported order explicit. Test with a small set of rows before importing a larger data set.

Use the right import mechanism

This page covers tab-separated data processed by ViewModel SeekLogic. Use the mechanism that matches the source data and import scope.

Need Use
Paste tab-separated rows into a seeker and create or update objects ViewModel seeker import
Trigger tab-separated import through selfVM.ImportTabSepData and ViewModel search expressions HowTos:Import Tabular Separated Data Using OCLOperators
Import from another SQL-based system through MDrivenServer HowTos:Import Data from Other SQL Servers
Import several SQL tables and establish associations after import Documentation:SQLImport multiple tables with associations
Create objects from structured XML Documentation:OCLOperators XmlToObjects

See also