MS CRM 4 Form Printing - "This form has been changed and must be saved before printing"

I have come across an issue with Printing a CRM 4 form today. The messege "This form has been changed and must be saved before printing" appeared when I tried to print a form even though the form data is already saved.
After digging into the problem I found that this perticular form had two custom controls (textbox and a command button), because of this CRM was assuming this form has unsaved (isdirty true) data.
There is a workaround to solve this issue by changing the printing javascript in the main form script file.
First you have to log in to the CRM applicaiton server and go to the following location;
":\inetpub\wwwroot\_static\_forms\controls"
In this location you can find a file named "form.crm.htc". Open this file and find the print function which should look like this;

function Print()
{
if (isDirty())
{
alert(LOCID_FORM_PRINT_DIRTY_MESSAGE);
}
else
{
var sId = _oSubmitForm.crmFormSubmitId.value;
openStdWin(prependOrgName("/_forms/print/print.aspx?objectType=" + _oSubmitForm.crmFormSubmitObjectType.value + "&id=" + sId + "&title=" + CrmEncodeDecode.CrmUrlEncode(parent.document.title)), "print" + buildWinName(sId));
}
}

You can edit the above function to skip the isdirty check for the perticular entity which has custom controls. This will bypass the above mentioned messege and will go directly to printing. Change would be to the if condition for isdirty checking which should be the following;

if (isDirty() && _oSubmitForm.crmFormSubmitObjectType.value != 112)

112 is the objecttypecode for Case, you can change this to your disered entities objecttypecode. Hope this will help you, please drop a comment if you have any issues.

Permlink

0 comments:

 
Blog Directory - OnToplist.com