Skip to main content

Vault API Reference Guide

The M-Files User Interface Extensibility Framework 2.0 leverages the structures and methods defined within the M-Files gRPC API, thus has a slightly different structure and approach to other development environments such as the Vault Application Framework.

The gRPC API approach is inherently asynchronous by nature. For example, retrieving the object types from the vault may look like this:

function OnNewShellUI(shellUI){
      // Wait for the ShellFrame to be created and started
shellUI.Events.Register(
MFiles.Event.NewShellFrame,
shellFrame => {
shellFrame.Events.Register(
MFiles.Event.Started,
async () => {
Start( shellUI, shellFrame )
});
});
}

// Main application
async function Start( shellUI, shellFrame ) {
      // Retrieve the object types from the vault.
const objectTypes = await shellUI.Vault.objectTypes.getObjectTypes();
}

Unlike older implementations of the User Interface Extensibility Framework, data provided to methods, and data returned from methods, are simple JavaScript objects; there is no need to declare "new MFiles.ObjVer()" or similar. For example, creating a property value for use when creating an object might look like this:

// Name or title property.
const nameOrTitlePropertyValue = {
      property_def: BuiltInPropertyDefs.NameOrTitle,
      value: {
            type: 1, // Datatype.DATATYPE_TEXT,
            is_null_value: false,
            data: {
                  text: "My object"
            }
      }
};

We have also preferred methods which naturally operate on multiple objects over methods that operate on just a single one. For example: you will notice that CheckInMultiple exists, but that there is no method that checks in just a single object. If you do need to check in just one object then simply pass a single set of data in the various arrays.

Delegating work to M-Files Server

When working within the User Interface Extensibility Framework, you may find that you need to make multiple calls to the M-Files server via the Vault API. This can be verbose and difficult. Instead you may decide to expose a Vault Extension Method and implement the complex logic on the server side, then call the vault extension method from your UI Extension:

// TODO.
tip

Code run within a vault extension method will typically run within a single vault transaction. For this reason alone it is often a good idea to run more complex code server-side and allow it to succeed or fail atomically.