RE: How to open webresource in Dynamics 365 for Mobile?
Hi Clofly,
I tried your code like this:
function openWebResourceFunc() {
var client = Xrm.Utility.getGlobalContext().client.getClient();
if (client === 'Mobile') {
try {
var confirmStrings = { text: "You're in " client " client.", title: "Notice" };
var confirmOptions = { height: 150, width: 250 };
Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
function(success) {
if (success.confirmed) {
var windowOptions = { openInNewWindow: true, height: 400, width: 400 }
//Add
alert('Ready to open webresource');
Xrm.Navigation.openWebResource("cr1e3_custombutton", windowOptions);
// Try deprecated api if above not works
// Xrm.Utility.openWebResource("webresource name");
console.log("Dialog closed using OK button.");
} else {
console.log("Dialog closed using Cancel button or X.");
}
});
} catch (err) {
openAlert("Oh..", "An error occured: " err, "Ok");
}
} else {
openAlert("Hi", "The function only works on mobile client", "Close");
}
}
function openAlert(titleContent, textContent, buttonContent) {
var alertStrings = { confirmButtonLabel: buttonContent, text: textContent, title: titleContent };
var alertOptions = { height: 150, width: 250 };
Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
function success(result) {
console.log("Alert dialog closed");
},
function(error) {
console.log(error.message);
}
);
}
And I got the following message:
After click OK button, system didn't have any action, and back to list.
Others api works fine, but Xrm.Navigation.openWebResource has issue.
The function can be execute 3 days ago, but now it doesn't work.
Luis