Thursday, November 18, 2010

Refresh IFRAME loaded in grid

This is a very common problem when we load an area in IFrame. On addition of some records using 'Add existing' button, the grid doesn't refresh.
To help in generalisation the IFrame naming convention has to be "IFRAME_"+relationshipname.


eg: relation name is -- account_opportunity
Iframe name must be IFRAME_account_opportunity


This method is unsupported.


Script changes to be made in C:\Inetpub\wwwroot\CRM\_static\_grid\action.js :


/* In the function AssociateObjects,  we need to add the following code in two places.



var IFrame = "IFRAME_" + sAssociationName;
if (window != null && window.document != null && window.document.getElementById(IFrame) != null) {
    window.document.getElementById(IFrame).src = window.document.getElementById(IFrame).src;
}

In the two places - If and else condition ------  if ( parentInitiated ) condition and the else part. 



*/


CODE:



if ( parentInitiated )
{
for ( i=0; i < iLength; i++ )
{
commandAssociate.SetParameter("objectType", type1);
commandAssociate.SetParameter("parentObjectType", type2);
commandAssociate.SetParameter("objectId", id1);
commandAssociate.SetParameter("parentId", objs[i].id);
commandAssociate.SetParameter("associationName", sAssociationName);
if (!commandAssociate.Execute().Success)
{
break;
}
var IFrame = "IFRAME_" + sAssociationName;
if (window != null && window.document != null && window.document.getElementById(IFrame) != null) {
    window.document.getElementById(IFrame).src = window.document.getElementById(IFrame).src;
}
}
}
else
{
for ( i=0; i < iLength; i++ )
{
commandAssociate.SetParameter("objectType", type2);
commandAssociate.SetParameter("parentObjectType", type1);
commandAssociate.SetParameter("objectId", objs[i].id);
commandAssociate.SetParameter("parentId", id1);
commandAssociate.SetParameter("associationName", sAssociationName);
if (!commandAssociate.Execute().Success)
{
break;
}


var IFrame = "IFRAME_" + sAssociationName;
if (window != null && window.document != null && window.document.getElementById(IFrame) != null) {
    window.document.getElementById(IFrame).src = window.document.getElementById(IFrame).src;
}
}
}








No comments:

Post a Comment