Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Script Error Quick Create

$
0
0

Hi,

I have added a button to open a Quick Create Case form from a Customer Asset. This code is working well with legacy rendering but if I remove legacy form rendering if doesn't work. I want to remove legacy form rendering for performance issues, therefore I'd like to fix this bug (appears in 8.2 and 9.0). This is the bug caught in my browser:

Uncaught TypeError: Cannot read property 'onQuickCreateStopLoadCallback' of null
    at Function.Mscrm.GlobalQuickCreate.GlobalQuickCreateBehavior.$h (VM12664 JsProvider.ashx:11641)
    at HTMLAnchorElement.Mscrm.GlobalQuickCreate.GlobalQuickCreateBehavior.$U (VM12664 JsProvider.ashx:11641)
    at HTMLAnchorElement.b (MicrosoftAjax.js?ver=1084663560:2922)
Mscrm.GlobalQuickCreate.GlobalQuickCreateBehavior.$h @ VM12664 JsProvider.ashx:11641
Mscrm.GlobalQuickCreate.GlobalQuickCreateBehavior.$U @ VM12664 JsProvider.ashx:11641
b @ VM12049 MicrosoftAjax.js:2922

This is the look of the quick create form after I click on save. Note that the Case is actually created in the background:

This is my code to open the quick create form:

function openQuickCreateCase()
{
	Xrm.Page.ui.clearFormNotification();
	var serviceAccount= Xrm.Page.getAttribute("msdyn_account");
	//Check if Service Account has a Value
	if (serviceAccount!=null && serviceAccount.getValue()!=null )
	{
		var custAsset = {

		 entityType: "msdyn_customerasset",

		 id: Xrm.Page.data.entity.getId()

		};

		var parameters = {};

		// *** Call the Xrm.Utility needed to add a contact.
        Xrm.Utility.openQuickCreate("incident", custAsset, parameters).then(function (lookup) { successCallback(lookup); }, function (error) { errorCallback(error); });
        
	//If service account is empty then show error message.
	}
	else
	{
		Xrm.Page.ui.setFormNotification('Case Not Created Service Account missing ', 'ERROR', '1');
		Xrm.Page.getControl("msdyn_account").setNotification("This field should not be empty.")
		alert("The Service Account field is Empty.")
    }
}
		

// *** Function called on success.
function successCallback(lookup) {
	var formId = lookup.savedEntityReference.id;
	var parameters = {};
//Issue Below
	Xrm.Utility.openEntityForm("incident", formId, parameters);
	// alert("lookup: " + lookup.savedEntityReference.id);
	// alert("lookup: " + lookup.savedEntityReference.name);
}

// **** Function called on error.
function errorCallback(e) {
	alert("Error: " + e.errorCode + " " + e.message);
}


After investigating, I found out that if I remove my code from the successCallback, I don't see the issue:

// *** Function called on success.
function successCallback(lookup) {
	var formId = lookup.savedEntityReference.id;
	var parameters = {};
//Issue Below
	Xrm.Utility.openEntityForm("incident", formId, parameters);
	// alert("lookup: " + lookup.savedEntityReference.id);
	// alert("lookup: " + lookup.savedEntityReference.name);
}


What this code is doing is opening the form that was just created through the quick form since my Workflow is: User opens Customer Asset ==> Creates a Case from Quick Form ==> The Case is open on the screen.

Thanks in advance for your help!


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images