How to show Custom Ribbon Button while working offline on Mobile Device

By | February 19, 2021

Introduction:

Microsoft has provided the mobile offline feature to work with our data in offline mode even when we don’t have internet access. Mobile Offline features allows us to work with commands like create, read, update, and delete. Mobile offline features are currently available for iOS and Android devices.

You can refer the below link to know more about to work in offline mode.

https://docs.microsoft.com/en-us/dynamics365/mobile-app/work-in-offline-mode

In Dynamics 365 CRM, we can add custom ribbon button on Entity Form, Associated grid and Home grid using the Ribbon Workbench. But if the user is offline, custom ribbon button without the enable rule ‘Mscrm.IsEntityAvailableForUserInMocaOffline’ won’t be displayed on Mobile Device.

So, let’s see how to add ‘Mscrm.IsEntityAvailableForUserInMocaOffline’ enable rule in order to show custom ribbon button in offline mode as well on the mobile device apps i.e., Dynamics 365 for Phone and Field Service (Dynamics 365) apps.

In order to use OOB ‘Mscrm.IsEntityAvailableForUserInMocaOffline’ enable rule, we need to add ‘custom rule’ in the ‘Enable Rule’ with the OOB script’s function.

As shown in below screenshot, we have added ‘Test Button’ on the Work Order Entity Form. Next, we added the ‘Enable Rule’ with name ‘Mscrm.IsEntityAvailableForUserInMocaOffline’ and used ‘XrmCore.Rules.Online.IsEntityAvailableForUserInMocaOffline’ function of OOB ‘Main_system_library.js’ web resource. And also passed the ‘SelectedEntityTypeName’ Crm Parameter to the function.

Please refer below screenshot for the same:

Note: This method is not part of Dynamic 365 API document. So, it can be updated by Microsoft without any prior intimation.

After associating this ‘Enable Rule’ to the ‘Test Button’, publish the customization in the ribbon workbench using the ‘Publish’ button.

Once completed with the publishing changes, we can start using the mobile app in offline mode. As shown in below screenshots, we can now see this custom ‘Test Button’ on Work Order form in online and offline mode as well.

Online Mode:

Offline Mode:

Note: When adding this Enable Rule to use custom button in offline mode, make sure that this button uses offline JavaScript for the associated functionality.

Conclusion:

As illustrated above, by using ‘Mscrm.IsEntityAvailableForUserInMocaOffline’ Enable Rule we can show custom ribbon button on the mobile device in offline mode as well.

One thought on “How to show Custom Ribbon Button while working offline on Mobile Device

  1. Linn Zaw Win

    Thanks. This is a really helpful article. One of the rookie mistakes that I made was missing out “$webresource:” prefix in the Library parameter of the CustomRule when I copied the text in the blog post without looking carefully at the screenshot.
    $webresource:Main_system_library.js

Comments are closed.