CRM 2015 SDK: How to recognize user’s form factor and client

When you’re working on multi-device projects in Dynamics CRM, sometimes you need to know the form factor that the user is currently using in order to execute or note some UI actions using Javascript. Dynamics CRM 2015 makes it easier and suggests using the context object with getFormFactor() method that returns an integer between 0 and 3.

Javascript Code: Xrm.Page.context.client.getFormFactor()

Return Value

Form Factor

0

Unknown

1

Desktop (Warning that does not mean Computer, it can also be a desktop version used from a tablet navigator)

2

Tablet Application

3

Phone Application

Let’s apply this to a simple example, we will run an alert box containing the name of the form factor on form loading: