How to Perform Platform Specific Logic in Dynamics 365

When creating forms in Microsoft Dynamics 365, you may need to alter the design of a form or change the way you trigger specific events depending on the sort of device the user is viewing the form. Fortunately, this is easy with Dynamics 365, as useful functions are provided through the Xrm.Page api, specifically the client-side context.

There are two useful functions here, which can be used in conjunction to discover information about the user’s device.

clip image002 thumb How to Perform Platform Specific Logic in Dynamics 365

This can be useful when designing forms, as you may want to have the forms react in different ways depending on the form factor of the device used to view it, by hiding fields or sections, or you may need to determine which device is being used in order to make the experience of viewing the form consistent.

Note that this functionality is mainly useful when used for the ‘Main’ form, as the main form can be used for both mobile and desktop based devices.

A Quick Example – a Quirk of the Main Form When Used for Mobile Devices

When designing a form in Dynamics 365, there are instances when you may want the same field to appear on a form multiple times. This may be because these fields should have different labels depending on the section that they’re in, or they simply need to be replicated throughout the form.

Regardless of reason, a quirk of the main form is the indexing of multiple fields. Duplicate controls on a form can be iterated through by using a simple loop, and in some cases, you may want to perform a specific action on a control depending on the order.

 How to Perform Platform Specific Logic in Dynamics 365

However, when the main form is used on mobile devices the index for the header is the control at index 0, rather than the final control. In this instance, if you needed to perform some specific logic on this control, you would need to adjust the logic depending on the form type.

 How to Perform Platform Specific Logic in Dynamics 365

Let’s block ads! (Why?)

Magnetism Solutions Dynamics CRM Blog