Platform Targeting

Overview

The V3 client application definition schema introduced the ability for applications to define the platforms in which they should execute. Prior to V3 of the schema, applications only ever executed within the M-Files Desktop client.

The application must use the V3 schema (or later) to be able to use platform targeting; using the V1 schema will result in an error.

Available Platforms

There are currently two supported platforms:

  • Desktop (i.e. the code should execute within the M-Files Desktop client), and
  • Web (i.e. the code should be executed within the M-Files Classic Web).

The platform that each application supports is defined within the application definition file, in the following ways:

The entire appdef.xml file is shown, but only the <platforms></platforms> element changes in each sample; the rest is shown for completeness.

Declaring compatibility with only the M-Files Desktop client

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:noNamespaceSchemaLocation="http://www.m-files.com/schemas/appdef-client-v3.xsd">
	<guid>1B9552B3-C1C5-44b9-905F-D4ABAC5E7AE2</guid>	
	<name>My sample application</name>
	<version>0.1</version>
	<description>A demonstration application.</description>
	<publisher>M-Files Corporation</publisher>
	<copyright>(c) M-Files Corporation 2017</copyright>
	<required-mfiles-version>11.2.4320.49</required-mfiles-version>
	<platforms>
		<platform>Desktop</platform>
	</platforms>
	<modules>
		<module environment="shellui">
			<file>main.js</file>
		</module>
	</modules>
	<dashboards>
		<dashboard id="sampledashb">
			<content>sampledashboard.htm</content>
		</dashboard>
	</dashboards>
</application>

Declaring compatibility with only M-Files Classic Web

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:noNamespaceSchemaLocation="http://www.m-files.com/schemas/appdef-client-v3.xsd">
	<guid>1B9552B3-C1C5-44b9-905F-D4ABAC5E7AE2</guid>	
	<name>My sample application</name>
	<version>0.1</version>
	<description>A demonstration application.</description>
	<publisher>M-Files Corporation</publisher>
	<copyright>(c) M-Files Corporation 2017</copyright>
	<required-mfiles-version>11.2.4320.49</required-mfiles-version>
	<platforms>
		<platform>Web</platform>
	</platforms>
	<modules>
		<module environment="shellui">
			<file>main.js</file>
		</module>
	</modules>
	<dashboards>
		<dashboard id="sampledashb">
			<content>sampledashboard.htm</content>
		</dashboard>
	</dashboards>
</application>

Declaring compatibility with both platforms

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:noNamespaceSchemaLocation="http://www.m-files.com/schemas/appdef-client-v3.xsd">
	<guid>1B9552B3-C1C5-44b9-905F-D4ABAC5E7AE2</guid>	
	<name>My sample application</name>
	<version>0.1</version>
	<description>A demonstration application.</description>
	<publisher>M-Files Corporation</publisher>
	<copyright>(c) M-Files Corporation 2017</copyright>
	<required-mfiles-version>11.2.4320.49</required-mfiles-version>
	<platforms>
		<platform>Desktop</platform>
		<platform>Web</platform>
	</platforms>
	<modules>
		<module environment="shellui">
			<file>main.js</file>
		</module>
	</modules>
	<dashboards>
		<dashboard id="sampledashb">
			<content>sampledashboard.htm</content>
		</dashboard>
	</dashboards>
</application>

Targeting M-Files Classic Web (aka M-Files Web Access, or MFWA)

Unlike User Extensibility Framework applications running on the M-Files Desktop client - which have full access to the M-Files COM API model (in client mode) - applications that run within M-Files Classic Web have additional constraints:

Checking the current platform

The current platform can be checked programmatically by inspecting MFiles.CurrentApplicationPlatform.

On M-Files Classic Web, MFiles.CurrentApplicationPlatform returns 2. On M-Files Desktop, MFiles.CurrentApplicationPlatform returns 1. In versions of M-Files Desktop less than 12.0.6658.0, the value is incorrectly returned as undefined.