I am trying to create a simple alert as an onload
event on the contact entity. However, I only want this to trigger if one of the conditions is that the contact is still active.
I therefore put it the following:
if (crmForm.all.statecode.DataValue == 0)
{
alert("'Whatever alert I want") ;
}
However, when I load the contact record it errors. Is it not possible to base an 'if' statement on the status.
I think what you want is the crmForm.FormType enumeration:
http://mscrm-developer.blogspot.com/2008/09/crm-form-types.html
crmForm.FormType == 4 means the form is deactivated (statecode 1) so you could do something like
if (crmForm.FormType != 4) alert("Whatever alert I want");
Just be cautious of all the various form types that are out there and make sure you get the alert where you want it.