Form design considerations and best practices for Dynamics 365 Mobile app

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com
Spoiler alert! Unlike other blogs, I am not going to update you about any new feature. Rather I am going to share my project experience in handling multiple forms designed for your Web and Mobile layouts.
Scenario
You have exposed you CRM recently to Mobile Apps. When you expose your CRM to Mobile Application development, in most of the scenarios you would end up designing separate forms. Let’s take the example of Account entity. Say you have designed two forms

  • Account Web Form – This form is displayed to users while accessing CRM to Web
  • Account Mobile Form – Form displayed to users while browsing CRM on Mobile

And you have your users who will just access CRM through desktop and then some users accessing CRM through both Desktop and mobile.
So now the implementation
First of all, as I have been across client locations, I find that some consultants still assume that to expose a form in mobile, we need to create a form of type = ‘Mobile Express’. Mobile express forms were required for previous Dynamics app – Dynamics CRM Phone express. For the current version of Mobile App for Dynamics, Form Type = Main would work just fine
So what is the next step? We create a new form of type Main, this time specifically for mobile and put in only the fields required for Mobile as per the requirement. But wait, we have another form already exposed for the desktop. So how do we handle this.

  • Create a new security. Let us name it here – “Mobile User Security Role”. The privileges for this security role is optional and depends on your requirements.
  • Assign the security to users who need to access CRM on mobile.
  • In the Form order for Main Form set, set the Mobile form at the top of form order.

image

  • The next step is to leverage the role based forms. Expose the Account – Mobile form to only users with Mobile User Security Role.

image
Uncheck the “enabled for fallback” checkbox as well.

Save an publish your customizations.
All set and done. Now this works very well for users who does not use desktop and manages through mobile (hardly the case) and users not exposed to mobile platform. However the issue is for a user who has access to mobile and desktop version. They now see two forms and the mobile form starts showing up in the desktop as well as it is highest level in the form order as well.
The last step here is to switch the mobile if it loads on desktop. The simple piece of client side script would just work fine when put in form load of the mobile form.

function SwitchToDefaultFormForWebVersion(){
        var _defaultFormName = "account web form";
        var _isMobileClient = Xrm.Page.context.client.getClient() == "Mobile";
        if (!_isMobileClient) {
            var availableForms = Xrm.Page.ui.formSelector.items.get();
            var currentForm = Xrm.Page.ui.formSelector.getCurrentItem();
            if (currentForm != null) {
                var currentFormLabel = currentForm.getLabel();
                if (currentFormLabel.toLowerCase() == _defaultFormName)
                    return;
            }
            for (var i = 0; i < availableForms.length; i++) {
                if (availableForms[i].getLabel().toLowerCase() == _defaultFormName) {
availableForms[i].navigate();
                }
            }
        }
    }

Please remember that form navigation script is not supported on mobile. Hence first I am making the check if the client is Mobile.
Well there you go. Everything is up and running for you now.
Hope this helps!
Debajit Dutta
(Dynamics MVP)
For training/ consulting/ utilities – please visit our website – www.xrmforyou.com or write to us at info@xrmforyou.com


Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe to get the latest posts sent to your email.

2 thoughts on “Form design considerations and best practices for Dynamics 365 Mobile app”

Comments are closed.

Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading