×
Menu
Index

4.7. Importing documents from M-Files

 
The M-Files Import input module takes the objects of an M-Files vault that match a saved search, downloads their files into a batch and writes the result back to properties of the object (status, batch, information, number of pages...). Together with the M-Files export module, which can return the processed document to the same object, it closes the loop: documents dropped in M-Files are captured by ChronoScan and come back indexed, with their metadata filled in. The module works interactively from the Scan/Input tab and unattended from a hot folder task.
Requirements: the M-Files Desktop client on the station, which installs the M-Files API the module talks through; a saved M-Files connection with an account allowed to read, check out and check in the objects of the vault and to edit the properties you update; and, in the vault, a property that marks the state of each object (a value list or a text property), used by the search to pick only the pending objects and by ChronoScan to mark them as processed.
Connections and searches
Imports are defined by two shared objects, stored with the configuration of the installation and available to every job (see Where data and credentials are stored):
A saved search: connection, vault, object type and class, and a condition on the status property.
The conditions editor opened from Search by properties: the status property must be empty.
Execute search... lists the objects the search returns; the status property appears as a column because it is a returned property.
Deleted objects are always excluded from the search. The usual pattern is a status property of the vault (a value list with values such as INPROCESS and PROCESSED, or a text property) that is empty on the documents to capture: the search asks for an empty status, ChronoScan sets it to the "import OK" value when it takes the document, and the export sets it to the final value when it returns the processed document.
Creating an import configuration
In the Documents and Image Input toolbar of the Scan/Input tab select M-Files Import and click Start Input. The window Input documents from M-Files lists the configurations of the job; its menu offers New configuration, Copy configuration, Remove, Edit search (opens the searches window) and Test connection. Each configuration has these properties:
The buttons of the window: Import runs the configuration now into the open batch; Explore opens the search explorer, which runs the search of the configuration and lists the objects that would be imported; Finish closes the window.
What happens in a run
ChronoScan does not remember which objects it has already imported: an object that still matches the search is imported again in the next run. The search must therefore exclude the processed objects, normally through the status property (condition "status is empty", or "status <> PROCESSED"). An object left with the OK value is not taken again as long as the condition excludes that value.
M-Files fields of the imported documents
Every imported document carries system fields with the origin of the file, available in scripts, in the Variables Wizard and in the output modules as %docfield.name%:
Field
Content
sysmfiles.originalObjectID
ID of the object in the vault (the one to use to find the object again on export).
sysmfiles.OriginalObjID
Original object ID; the same value unless the object comes from a replicated vault.
sysmfiles.internalID
Internal ID of the object version that was imported.
sysmfiles.Title
Title of the object.
sysmfiles.ObjectFileID
ID of the file inside the object.
sysmfiles.ObjectFile
File name with extension.
sysmfiles.Search
Name of the search that found the object.
sysmfiles.isLastFileObject
true on the last document created from an object with several files, so a script knows when the whole object has been processed.
sysmfiles.prop.<Property name>
One field per property of the object (except multi-select lookups), with its value as text: Name or title, Class, Created by, Last modified, your own properties...
The Variables Wizard filtered by "sysm": the M-Files fields of a document, ready to be used in an export module.
Returning the document to M-Files
The export is configured with the M-Files export module (see also the M-FILES Export Guide and linking scanned documents to an existing object). To update the object that was imported instead of creating a new one, enable Search object to add/replace, search by ID with the value %docfield.sysmfiles.originalObjectID%, and choose whether to replace the file (for example the scanned TIFF by the indexed PDF) or add it. In the linked fields set the status property to its final value (PROCESSED in the example); with a value list property use the custom function search_mfiles_listvalue_id so the value is looked up in the list (Working with M-FILES Value Lists).
The vault after an import: the status property of the captured documents is INPROCESS until the export sets it to PROCESSED.
Hot folder
In the Tasks/HotFolder tab add a task with the module M-Files Import and one of the configurations of the job. On each sweep the task counts the pending objects of the search, creates a batch when there are documents to import and runs the import; the objects that are ignored or that only need their properties updated are dealt with during the count and do not create a batch. The rest of the task options (processing when the input finishes, export, notifications, run frequency) are the ones of any task, see HotFolder Tasks. In ChronoScan Enterprise the input server runs the same tasks. The task log and the Output window record the search, the objects found, the files imported or ignored and the properties written ("Object ... updated to ...").
The SharePoint import module works the same way for SharePoint libraries. A step-by-step example with screenshots is available in the M-Files Importer Quick Start and in the presentation ChronoScan M-Files Importer.