Context Menu

The Context Menu provides the capability of executing a SQL Procedure or navigate to a URL from M‑Files. The Context Menu is dependent on the M‑Files Desktop client. It is not available in M‑Files Web Access or Mobile.

This capability allows the following key features:

  1. Action button in the M‑Files task bar to open menu items

  2. Customizable menu items grouped by customizable group headings

  3. Open a URL in a new browser when a menu item is selected

  4. Execute a procedure in the Connector database when a menu item is selected

  5. Right‑click on an object and execute a menu item that runs a stored procedure with the selected object’s version details as input parameters

  6. Add a script in a workflow state action that executes a stored procedure in SQL

Refer to Installing the Context Menu for installing the Context Menu.

Refer to Using the Context Menu

Note that the Context Menu is installed and operates as a separate module of the Connector and requires the Data Exchange module to operate.

Context Menu Procedures

The context menu relies on procedures with a predefined structure.

The procedure spMFGetContextMenu is used by the application and should not be modified.

The functionality provides for two types of procedures to be executed:

  1. Procedure without any input parameters

  2. Procedure using the object version of the M‑Files object in context as an input parameter

The name of the procedure must be added in the column Action in MFContextMenu table for the menu item that will be used to execute the action.

The procedure will be executed when the menu item is selected. The intent is that this procedure will call the custom procedure that controls the execution of the desired process. On completion the output message of this procedure will be returned to the user in M‑Files.

Procedure without input parameter (action type 1)

CREATE PROCEDURE [contmenu].[procname]
 @OutPut varchar(1000) Output
 as
 Begin

   Begin Try
    --Call procedure to perform operation and return output message
    set @OutPut='Operation successful'
   End Try
   Begin Catch
    set @OutPut='Error:'
    set @OutPut=@OutPut+(select ERROR_MESSAGE())
   End Catch
 End

Procedure with object version as input parameter (action type 3)

CREATE PROCEDURE contmenu.procname
 @ObjectID int,
 @ObjectType int,
 @ObjectVer int,
 @OutPut varchar(1000) Output
 as
 begin
   Begin Try
 --Call procedure to perform operation using the object details as input and return output message
    set @OutPut='Operation successful'
   End Try
   Begin Catch
    set @OutPut='Error:'
    set @OutPut=@OutPut+(select ERROR_MESSAGE())
   End Catch
 End

Formatting result message for UI

The procedure spMFResultMessageForUI is targeted at providing a formatted message to be returned to the UI to improve the user message on completion of the procedure.

This procedure is called from the main procedure that controls the process to return an error or to signal successful completion. It also assumes that the main procedure utilizes the MFProcessBatch table to log to outcome of the procedure.

The message returned is the result of the procedure as recorded in the MFProcessBatch.

Line Breaks in output

Insert ‘n’ in the string to insert line breaks in the output message :

For example:

SET @OutPut= 'ObjectID='+CAST(@ObjectID as varchar(10))+ '/n' + ' ObjectType='+CAST(@ObjectType as varchar(10))+
+ '/n' + ' ObjectVer='+ CAST(@ObjectVer as varchar(10))