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

You can use ImportTabSepData in a ViewModel Seeker to create or update objects from tab-separated rows copied from Excel or produced by another MDriven application.

What the import does

selfVM.ImportTabSepData runs the import behavior of a Seeker ViewModel. The tab-separated text is supplied through the Seeker search value. Each line represents one object, and each tab-separated value maps to a column in the search-result grid.

The import uses the first column as the key:

  • If the Seeker finds an existing object for the key, the import updates that object.
  • If no object is found, the import looks for a ViewModel action named CreateNew. When that action is available, it creates an object, adds it to the search result, and the import applies the row values.
  • If no object is found and no suitable CreateNew action is available, the row cannot create a new object.

The columns after the key are applied according to the result-grid column configuration. Editable columns can receive values. Read-only columns are skipped.

Configure the Seeker ViewModel

Create a normal Seeker ViewModel for the class you want to import. The Seeker search criteria determines how the first-column key is matched.

  1. Add the key attribute as the first search-result grid column.
  2. Add each attribute that you want to import as a subsequent result-grid column.
  3. Make each column that should receive imported data editable.
  4. Leave columns read-only when the import must not change them. A read-only column is skipped.
  5. Make the default search field, vSeekParam, multi-line. This allows pasted clipboard data to retain both tab characters and line breaks.
  6. Add a ViewModel action named CreateNew if the import must create objects for keys that do not already match the Seeker criteria. The action must create an object of the class handled by the Seeker.
  7. Add an action that invokes selfVM.ImportTabSepData.
selfVM.ImportTabSepData

Define CreateNew as a ViewModel or class action that the Seeker can find. Do not rely on an unrelated action defined only in the Action Editor.

Import tab-separated rows

Paste data into the multi-line search field, then invoke the action that calls ImportTabSepData.

For a Seeker whose result grid starts with Guid and then Name, paste data such as:

793e00a1-7e61-4261-a2ed-7e9047e2c5c4	My new value 1
6d47193c-e4b9-486b-827d-104e01466a81	My new value 2
f084a714-2ae6-43a5-8862-74c912861aae	My new value 3

The import searches separately for each first-column value. If a matching object is found, its editable Name column is updated. If you paste a previously unknown key and the Seeker provides CreateNew, the action creates a new object and the import assigns the row values.

Input position Meaning Example
First column Key used to find an existing object through the Seeker criteria. 793e00a1-7e61-4261-a2ed-7e9047e2c5c4
Later columns Values assigned to corresponding editable result-grid columns. My new value 1
Each line One create-or-update operation. One object per pasted row

Key types and matching

The first value arrives as text. For string keys, use vSeekParam in the Seeker criteria.

If the key is a Guid or Integer, define the corresponding additional Seeker variable so that the import can populate it before the search:

Variable Type Use
vSeekParam String Standard Seeker parameter and text key input.
vSeekParamAsGuid Guid Populated when the first-column value parses as a Guid.
vSeekParamAsInt Integer Populated when the first-column value parses as an Integer.

For example, use vSeekParamAsGuid in the Seeker criteria when the first column contains Guid values. This avoids comparing a string search parameter directly with a Guid value.

Import attributes and single links

The import follows the result-grid columns in order. Keep the pasted column order aligned with the grid order.

A combobox column can set a single link. The import string-matches the pasted value against the combobox values and assigns the matching object. Design the ViewModel picklist and associated ViewModel class so that the displayed value is an unambiguous lookup value.

For example, if an imported Product row includes a category name in a combobox-backed Category column, the import can match that category name and set the Product-to-Category single link. For combobox setup guidance, see HowTos:Create Comboboxes with Strings.

Required input format and limits

  • Use a tab character between columns and a new line between rows. Copying a rectangular range from Excel normally produces this format.
  • The first column is always the lookup key; it is not optional.
  • Each row must contain a tab character. This matters when you import one visible value per row: include another tab-separated column rather than supplying plain one-column lines.
  • Read-only result-grid columns are not written by the import.
  • The import handles attributes and single links represented by the Seeker grid. For larger multi-table SQL imports and association strategies, see Documentation:SQLImport multiple tables with associations.
  • Save the changed objects using the normal save flow after the import.

Use tabular data for synchronization

Because this behavior belongs to ViewModel Seeker logic, the same import pattern can run in Turnkey, VMClass, code-generated ViewModels, WPF, the debugger, and server-side ViewModels in MDrivenServer. A sending application can produce tab-separated grid data with GetGridAsTabSepData, set the receiving Seeker's vSeekParam, execute the search/import flow, and save the resulting changes.

For the broader import, export, multi-search, and synchronization pattern, see Documentation:Convergence – ViewModels, import, export, multi search, synchronization and Excel.

Example model

The downloadable example model demonstrates this setup:

File:ImportTabSepExample.modlr

See also