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