Data model

Import functions

In the Excel import you can attach a small function to each column that reshapes the cell before the field type checks it. This is how “Meier, Hans” becomes “Hans Meier”, two columns become one value, or an existing value stays protected.

Functions you need again and again are stored as templates in a library. You find it under Data model › Import functions (status 9). You can group the list by scope or by name, and the selection next to it filters (All, One field, One field type, All fields, Defaults only). Clicking a template opens it in the Edit template dialog. You can also create a template directly during an import.

“Edit template” dialog for the import function “Höhe aus der Maßangabe” with name, description, Applies to “One field”, the field Höhe, the “Use as default” tick, the function in the code editor and the test below it.

A template

PropertyMeaning
NameThe name under which the template appears during import
DescriptionWhat it is for
Applies toAll fields, One field type or One field
Use as defaultThe template is active as soon as a matching column is mapped, visible and possible to switch off
FunctionThe body that returns the new cell value
Try itEnter test values and see the result or the error message straight away

Built-in functions

Under Built in you find the functions that come with Moliri: Split dimensions into height, width, depth and diameter, Dating → from and to, Cut off the unit, mm → cm, Inches → cm, Excel day count → date, Date, day first, Yes/no → switch and Split a list at its separator. What they read is described in the Excel import . They cannot be changed or deleted. A click opens one with its function and test, and Save creates a copy of your own that you can then adapt. During import they only appear on fields they were written for, and never as a default.

Defaults

A template with Use as default is a preset for the import: when you map a column to a matching field, the function is already active. If there are several defaults, the narrower one wins: One field before One field type before All fields. The Defaults only filter shows them in the list.

A function attached to a column during import is a copy. Changing or deleting a template does not change imports that are already in progress.

What a function sees

NameContents
wertThe cell of this column as text
zeileAll cells of the same row, by column heading: zeile['Vorname']
objektWertWhat the target field currently holds, if the row is matched to an existing object. Otherwise null
objektAll fields of the matched object, by field name. Empty if there is no match
leerleer(v) is true for a missing or empty value

Some examples:

JS
// two columns into one value
return zeile['Vorname'] + ' ' + zeile['Nachname'];
JS
// protect what is already there
return objektWert || wert;
JS
// append instead of replacing
return objektWert ? objektWert + '; ' + wert : wert;

The same subset of JavaScript is allowed as for virtual fields, see Creating a virtual field . A function can only read the data, never change it. Anything that is not allowed is reported before saving (This function is not allowed.).

Order during import

The function runs first. After that the field type checks the value as usual: a select list matches it against its options, an authority field looks up the term, a JSON field accepts a document. Anything that then does not match unambiguously is parked and marked to resolve.

Further reading