Wednesday, January 21, 2009

Dynamic CRM 3.0 - Print Unsaved Data

Microsft Dynamic CRM 3.0 never alows you to print unsaved data. System check the availability of dirty data. Lets see how to stop this dirty check and print unsaved data.

first we have to find the print() function. open WWWROOT folder and go to INETPUB in your machine.

Then open this folder :\Inetpub\wwwroot\_forms\controls

Open form.crm.htc file

find the Print() function.

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

Here you can see that system check dirty values on the form. so edit the code according to your needs and skip validating dirty values. Then you can print your CRM form.

Following example shows how to skip this dirty check for a specific entity using the object type code.

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

Welcome 2009