3. User messages and notifications

3.1. Scenarios

  • Sending targeted user messages during integration runs

  • Bulk emails and opt‑out handling

  • Integrating with external notification platforms

3.2. User messages in M‑Files

  • System failures are logged to MFLog and can be emailed to a support address configured in MFSettings.

  • Core processes can post user‑visible messages via MFProcessBatch with LogType = ‘Message’, which a trigger surfaces in MFUserMessages using spMFResultMessageForUI.

  • Add MFSQL Message and MFSQL Process Batch properties on relevant classes to surface messages per object; populate these in your custom procedures.

3.3. Bulk email notifications

Version 4.9.26.67 introduced templated bulk email via Database Mail. - Define templates in MFEmailTemplate. - Convert result sets to HTML via spMFConvertTableToHtml. - Send HTML emails via spMFSendHTMLBodyEmail. - Track outcomes in MFEmailLog.

3.4. Best practices

  • Enable Database Mail and set the SupportEMailProfile and SupportEmailRecipient settings in MFSettings (see How MFSQL alerts on errors).

  • Use a TestOnly parameter during development to avoid mass mail.

  • Drive table content for emails with parameterized SELECT that writes into a temporary table (##report) from ObjID.

3.5. Detailed guide

3.5.1. How MFSQL alerts on errors

System failures are logged in the MFLog table. Every row added to MFLog fires the trigger tMF_OnError_SendEmail, which emails the error to the support recipient set in MFSettings:

  • Database Mail must be installed and configured on the SQL Server, with a mail profile. Without a valid profile no email is sent; the error is still in MFLog.

  • SupportEMailProfile: the Database Mail profile to send with.

  • SupportEmailRecipient: the address or addresses to send to, separated by semicolons. Set it to your own support mailbox or team.

Only errors written to MFLog raise an email. Custom integration procedures must log their errors to MFLog to be covered; see Logging in custom procedures.

MFSQL does not write to the Windows Event Log. To alert through the Event Log or a monitoring tool, use SQL Server Agent job notifications on the jobs that run your integrations, or SQL Server alerts. The logging tables are described in Logging Tables.

Read the latest errors:

SELECT TOP 10 * FROM MFLog ORDER BY LogID DESC;
Example of a user message banner in M-Files

User message banner example in the M-Files UI. :alt: Access error message in MFLog

3.5.2. Get error messages to email

  1. Install and configure Database Mail on the SQL Server, with a mail profile.

  2. Set the profile and the recipient addresses (semicolon-separated) with spMFsettingsForDBUpdate. @EmailProfile writes SupportEMailProfile and @SupportEmailAccount writes SupportEmailRecipient.

  3. Check the settings. The recipient must be your own mailbox, not the address used in examples.

EXEC dbo.spMFSettingsForDBUpdate @SupportEmailAccount = N'mfsql-alerts@yourcompany.com',
                                 @EmailProfile        = N'YourMailProfile';

SELECT Name, Value
FROM dbo.MFSettings
WHERE Name IN (N'SupportEMailProfile', N'SupportEmailRecipient');
Example of a user message with details

User message with additional details visible to the user. :alt: Example email configuration

3.5.3. Add process messages to individual objects

To show per‑object messages on the metadata card, add two properties: MFSQL Message and MFSQL Process Batch, and ensure columns exist in the class table:

ALTER TABLE dbo.MFCustomer
  ADD mfsql_Message NVARCHAR(4000), mfsql_Process_batch INT;

Populate these fields in your custom procedures; include the ProcessBatch ID to link back to logs.

Context message dialog example

Context message dialog with action options. :alt: Message on metadata card

3.5.4. Get standard process messages in M‑Files

Core processes can generate entries in MFUserMessages, surfaced via a view in M-Files. Enable via MFSettings:

EXEC dbo.spMFSettingsForDBUpdate @UserMessageEnabled = '1';
Result notification example

Example of a result notification for an operation. :alt: Example of process message in M‑Files

3.5.5. Add custom message in MFUserMessages

User‑facing messages can be triggered by inserting MFProcessBatch rows with LogType = ‘Message’; a trigger will insert into MFUserMessages using spMFResultMessageForUI.

SET @Msg = 'Session: ' + CAST(@SessionIDOut AS VARCHAR(5));
IF @UpdateRequired > 0 SET @Msg += ' | Update Required: ' + CAST(@UpdateRequired AS VARCHAR(5));
IF @LaterInMF > 0        SET @Msg += ' | MF Updates : '      + CAST(@LaterInMF AS VARCHAR(5));
IF @Process_id_1 > 0     SET @Msg += ' | SQL Updates : '     + CAST(@Process_id_1 AS VARCHAR(5));
IF @Process_id_1 > 0     SET @Msg += ' | SQL New : '         + CAST(@NewSQL AS VARCHAR(5));

SET @LogText = @Msg;
SET @LogStatus = 'Completed'; -- 'Error' or 'Fail' will also trigger a message

EXEC dbo.spMFProcessBatch_Upsert
          @ProcessBatch_ID = @ProcessBatch_ID OUTPUT,
          @ProcessType     = @ProcessType,
          @LogType         = N'Message',
          @LogText         = @LogText,
          @LogStatus       = @LogStatus,
          @Debug           = @Debug;

3.5.6. Show process results in context menu action

Context menu actions can return a completion message for synchronous operations. See Using the Context Menu.

3.5.7. Process custom messages by Email

Use MFProcessBatch and MFProcessBatchDetail for content, then send via Database Mail using a custom procedure.

Implementation Examples:

For complete email notification implementations, see: - Comprehensive Workflow Integration Template - Advanced template with automated email notifications for error conditions, including HTML table generation and multi-recipient handling

Web client user message example

User messages shown in the M-Files web client. :alt: Summary email example

Desktop client user message example

User messages shown in the M-Files desktop client. :alt: Detail email example

3.5.8. Bulk email: components and setup

From this guide:

  • Components: - MFEmailLog - MFEmailTemplate - spMFConvertTableToHtml - spMFSendHTMLBodyEmail

  • Configuration steps (abridged): - Prepare class tables and triggers for recipients/events. - Configure the triggering event (e.g., workflow state change); context menu can help stage actions. - Design and insert the email template into tbMFEmailTemplate with placeholders ({head}, {firstname}, {user}, {table}). - Build a custom procedure to orchestrate the send: refresh data, replace placeholders, generate table, loop recipients, send, log, handle errors.

Reference Implementation: - Comprehensive Workflow Integration Template - Complete example showing email template usage, HTML table generation, error handling, and multi-recipient bulk email processing

Send bulk email example

Example table layout included in a bulk email. :alt: Example notification with table

3.5.9. Testing and staging

  • Use TestOnly to prevent bulk sends during dev.

  • Review MFEmailLog, clear rows for re‑send scenarios when intentional.

  • Stage notifications via agent batch, object change events, or manual execution—depending on use case.

3.6. See also