Thursday, June 24, 2010

Refresh a CRM grid on the CRM Form in MS CRM 4.0

try
{
var _locAssocObj = locAssocObj;
locAssocObj = this.locAssocObj;

//fucntion definition for overloading the N:N Grid association
this.locAssocObj = function(iType, sSubType, sAssociationName, iRoleOrdinal) {
_locAssocObj(iType, sSubType, sAssociationName, iRoleOrdinal);
switch (sAssociationName) {
case "new_new_opportunity_systemuser":
crmForm.all.IFRAME_OpportunityUser.contentWindow.document.all.crmGrid.Refresh();
break;
}
}

} catch (e)
{ }


“sAssociationName” is the relationship name (we can find this in entity customization).
Here there is an N:N relationship in between Opportunity and SystemUser named “new_new_opportunity_systemuser”.
And the system user grid is there on the CRM. On addition/removal of any entry in the user list will refresh the corresponding grid.