web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Need to update my modal dialog box with custom html web resource to be compatible with the UCI

(0) ShareShare
ReportReport
Posted on by 19

I have a button on a ribbon which runs a script to open a dialog box, in which the user can create recurring monthly records.
It no longer opens in the CRM UCI, and my understanding is that it is because the modal dialog method used was deprecated.

I am attempting to re-code it, but have not been successful.  See old code and new code below...

Old code:

//Open Modal dialog
function openModal() {
debugger;
var deadLineDate = Xrm.Page.getAttribute('xrm3_1stdeadlinedate');
if (deadLineDate == null || deadLineDate == undefined) {
alert("A required field was removed from the form. Contact your CRM administrator to review. -1stdeadlinedate");
return;
}
var dDate = deadLineDate.getValue();
if (dDate == null || dDate == undefined) {
alert("You must enter a deadline date.");
return;
}
var DialogOption = new Xrm.DialogOptions();
DialogOption.width = 315; DialogOption.height = 340;
var url = "/WebResources/xrm3_/htm/recurrence.htm";

Xrm.Internal.openDialog(Mscrm.CrmUri.create(url).toString(),
DialogOption,
null,
null,
CallbackFunction);

}
//modal windoow returned values
function CallbackFunction(returnValue){
debugger;
if(returnValue == null ) return;
if (returnValue.recurValue == null || returnValue.recurValue == undefined) return;
if (returnValue.recur == null || returnValue.recur == undefined) return;

Xrm.Page.getAttribute('xrm3_recurringfrequency').setValue(returnValue.recur);
Xrm.Page.getAttribute('xrm3_quantity').setValue(returnValue.recurValue);

createRecurring();

}

New code:

//Open Modal dialog
function openModal() {
debugger;
var deadLineDate = Xrm.Page.getAttribute('xrm3_1stdeadlinedate');
if (deadLineDate == null || deadLineDate == undefined) {
alert("A required field was removed from the form. Contact your CRM administrator to review. -1stdeadlinedate");
return;
}
var dDate = deadLineDate.getValue();
if (dDate == null || dDate == undefined) {
alert("You must enter a deadline date.");
return;
}

Xrm.Utility.openWebResource("xrm3_/htm/recurrence.htm",null,500,420);

var pageInput = {
pageType: "webresource",
webresourceName: "recurrence.htm"
}
var navigationOptions = {
target: 2,
width: 315, // value specified in pixel
height: 340, // value specified in pixel
position: 1
}
}

Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
function success(openModal) {
// Run code on success
},
function error() {
// Handle errors
}
);

}
//modal windoow returned values
function CallbackFunction(returnValue){
debugger;
//alert(returnValue);
if(returnValue == null ) return;
//if (returnValue.startDate == null || returnValue.startDate == undefined) return;
if (returnValue.recurValue == null || returnValue.recurValue == undefined) return;
if (returnValue.recur == null || returnValue.recur == undefined) return;

Xrm.Page.getAttribute('xrm3_recurringfrequency').setValue(returnValue.recur);
Xrm.Page.getAttribute('xrm3_quantity').setValue(returnValue.recurValue);
//Xrm.Page.getAttribute('xrm3_1stdeadlinedate').setValue(startDate);

createRecurring();

}

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    You will have to refactor your updated code in order to use navigateTo the proper way. I provided some additional information here - butenko.pro/.../

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 74

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans