Automated update of records from M-Files

Updating a class table is not automatically called on a change of a record in M-Files. There are various methods that can be used to action or schedule an update.

If SQL standard edition is used for MFSQL Connector, then use and SQL Agent job. refer to Using Agent for automated updates for more details

If SQL express edition then use the powershell special add in to schedule a task.

In either case the procedure spMFUpdateAllncludedInAppTables will allow for both incremental and full updates.

We recommend to schedule an incremental update with an appropriate interval for your needs as well as a full update at least once a day.

Note

Records deleted in M-Files is not picked up by the incremental update. It requires a full update to be picked up.

Updates on Demand

Updates triggered by an M-Files event

Before making change in SQL

The general rule is to always update from M-Files before a record is changed in SQL.  This is done by first calling the spMFUpdateTable with method 1 for the records that will be updated and then to call spMFUpdateTable with update method 0 after the the SQL record is update to push to update back to M-Files. The procedure spMFUpdateMFilesToMFSQL is particularly valuable in this regard.  Depending on the requirement and volume of data to be taken into account other update procedures can also be used as outline in section Insert Update of Class Records.

Using an agent

If the requirement is to refresh the class tables at intervals (for instance overnight, or every 2 hours) an agent can be used with

On Demand in external application

An action button in the external button (e.g. Code on Time action) can call spmfUpdateTable with update method 1; alternatively spMFUpdateTablewithLastModifiedDate can be used.

Action from within M-Files using Context Menu

The M-Files Context Menu plug-in allows to call any one of the updating procedures by activating the update from within M-Files.  The two options include triggering the procedure without any object level parameters and one that allows for the selected object parameters to be passed through to the procedure.

Note

The rows in MFContextMenu controls the operations of the action menu in M-Files. Check this table if the action item does not work. In particular, ensure that column IsProcessRunning is not stuck on 1.

Action as part of a workflow script

We are currently working on a method that will allow for calling the procedure by using the context menu vault application from a workflow.  This will trigger the update from the workflow state change.