Error "Object reference not set to an instance of an object" on Date Field Update


Audit Plugin fires error message “Object reference not set to an instance of an object” when Calendar Field filled out for the first time. However audit functionality is not affected by this error. Any future updates of calendars do not cause any error.


i_infinity wrote May 27, 2009 at 2:37 PM

Source code did not cover case when internal attribute such as “timezoneruleversionnumber” (in case of Contact) gets modified. Because these attributes do not have “Display Name” property, attempt to retrieve it generated unhandled error.

Avoid retrieving display name of internal attribute:
auditDetail.Properties["custom_display_name"] = metaAttribute.DisplayName.UserLocLabel.Label;

wrote Jun 24, 2009 at 4:19 PM

cmac2067 wrote Sep 3, 2009 at 6:02 PM

You can also force a display name on a couple of attributes through the backend (CRM DB) which fixes the problem.
begin tran
insert into MetadataSchema.LocalizedLabel (LocalizedLabelId,LocalizedLabelRowId
select newid(),newid(),1033,Attributeid,'DisplayName','TimeConv',1,0
from MetadataSchema.Attribute a inner join MetadataSchema.LocalizedLabel l
on a.attributeid=l.objectid where name in ('timezoneruleversionnumber','utcconversiontimezonecode')
and languageid=1033 and objectid not in (select objectid from MetadataSchema.LocalizedLabel where ObjectColumnName='DisplayName')

wrote Jul 6, 2010 at 10:17 AM

davideison wrote Feb 10, 2011 at 11:05 PM

Haven't personally tripped on this case, but I believe below should work?

Replace auditDetail.Properties["custom_display_name"] = metaAttribute.DisplayName.UserLocLabel.Label;


try {
auditDetail.Properties["custom_display_name"] = metaAttribute.DisplayName.UserLocLabel.Label;
} catch (Exception e) {
auditDetail.Properties["custom_display_name"] = metaAttribute.LogicalName;

dave0109 wrote Nov 29, 2011 at 8:55 AM

Hi all, where do I make this amend?

wrote Feb 14, 2013 at 1:59 AM