Skip to main content

Notifications

Announcements

No record found.

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();

}

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: Need to update my modal dialog box with custom html web resource to be compatible with the UCI

    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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,703 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans