vrijdag 19 september 2008

Refreshing a parent window when crmForm.IsDirty

When you try to refresh the parent window from an ISV page and the crmForm was
modified but not saved, you will get a confirmation dialog from CRM asking you
to continue or cancel the action.

To disable this behaviour you can Save the CRM form before the refresh action.

This seems to be standard CRM behaviour. You can try this when modifying an
account and then deactivating it. The new values will be saved automatically and
the account will be deactivated.

Put the following code in the OnInit of the aspx page:

protected override void OnInit(EventArgs e)
{
// Check if the crmForm was modified.
Response.Write("<script>" + "\n");
Response.Write("if (window.dialogArguments.document.crmForm.IsDirty == true)" + "\n");
Response.Write("{" + "\n");

Response.Write(" window.dialogArguments.crmForm.Save();" + "\n");
Response.Write("}" + "\n");
Response.Write("</script>;");

base.OnInit(e);
}

Regards,

Kenny