CRM 2011 – Sharing records in IFRAME

Unfortunately, if you want to use the sharing dialog in an IFrame, you’ll receive several errors (most of them regarding _a.length object).

To solve the issue, you can try the following workaround. It’s not supported, but it’s safe. Still, I recommend you backup any file before modifying it.

Go to %programfiles%\Microsoft Dynamics CRM\CRMWeb\_grid\cmds and edit the dlg_share.aspx file with administrative privileges (so you can overwrite it).

We’ll alter the window.onload() function and the acceptchanges() function (this one is called when the OK button is clicked).

And here’s the code:

 // Custom code - Variables 
var sharingEntityType = -1; 
var sharingEntityId = null; 
// End of Custom code
function window.onload()

// Custom code - IFrame Sharing Record Support
// Check if the passed ids array is null or undefined
if(_a == null || _a == undefined) {
	// Define the ids array
	_a = new Array();

	// Get the record id and store it into the array
	//_a[0] = parent.document.crmForm.ObjectId; // CRM 4.0
	_a[0] =; // CRM 2011

	sharingEntityType = _iObjType;
	sharingEntityId = _a[0];
// End of Custom code

function applychanges()

// Custom Code
if(sharingEntityType != -1 && sharingEntityId != null)
	// Set the Record URL to be reopened 
	// Refresh will be somehow simulated. 
	// A better refresh version, in which the closeWindow() method won't do whatever it wants is yet to come ;)
	var entityURL = "http://" + + "/Novensys/main.aspx?etc=" + sharingEntityType + "&extraqs=%3f_gridType=" + sharingEntityType + "%26etc=" + sharingEntityType + 

"%26id=" + sharingEntityId + "%26rskey=47983894&pagetype=entityrecord";, "CRMEntityPopup", "status=0,toolbar=0,scrollbars=0,resizable=1");
// End of Custom Code

To download the full dlg_share.aspx file, click here.

Leave a comment

Your email address will not be published. Required fields are marked *