简体   繁体   中英

Navigating in the dynamics 365 CRM App

I have a Dynamics CRM 2016 Online installation. I have created a web resource in this application. This web resource is launched from a button in the account list.

On the desktop this works perfectly, it launches a new window and I can do what I need and then navigate to a new record in crm with

Xrm.Utility.openEntityForm(entity, entityId);

and then close the window with

window.close();

I can also access this webbresource in the (iOS) phone app. But neither of the above two commands work when the resource has loaded.

I can't navigate from the webresource to a record using any of these commands:

Xrm.Utility.openEntityForm(entity, entityId); // throws undefined error
window.open(recordURL); // does nothing
window.location.href = recordURL; // does nothing

And I cannot close the webresource with either of these:

window.close(); // does nothing
window.history.go(-1); // goes to a blank page (even more infuriating).

Are there some specific javascript commands for these things (navigate to record, or go back)? I can't seem to find any references to what commands I should be using in the dynamics 365 app.

This Microsoft documentation site has some information about mobile devices:

"Additionally, Dynamics 365 for phones does not support web resources and IFRAMES so the client APIs for these controls won't work. Client APIs for web resources and IFRAMES are supported on Dynamics 365 for tablets though."

"Dynamics 365 mobile clients also do not support the window.open method . If you are looking to open an entity form for a new or existing record, use Xrm.Utility.openEntityForm instead."

So the window functions are not supported. Xrm.Utility.openEntityForm() should work though. Maybe a web API request doesn't deliver a required guid for the function call due to a bad internet connection on mobile devices.

Maybe it's just not supported as well, but nowhere documented. Atleast a very similar function Xrm.Utility.openWebResource() is not supported as state here: Xrm.Utility.openWebresource()

Keep in mind that you have to use parent.Xrm to access the Xrm object inside of webpages that are embedded as an iframe inside a entity form. That counts for webpages opened by window.open() too.

In case it will just not work you could still do some kind of conditional behavior or fallback:

var isCrmForMobile = (Xrm.Page.context.client.getClient() == "Mobile")
if (isCrmForMobile)
{
   // Code for CRM for phones and tablets only goes here.
}
else
{
   // Code for web browser or CRM for Outlook only goes here.
}
if (Xrm.Page.context.client.getClient() == "Mobile" && Xrm.Page.context.client.getFormFactor() == 3)
{
   // Add code that should only run in CRM for phones here
}
// Code for any client goes here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM