This project is read-only.
4
Vote

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

description

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.

comments

i_infinity wrote May 27, 2009 at 3: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 5:19 PM

cmac2067 wrote Sep 3, 2009 at 7: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
,LanguageId,ObjectId,ObjectColumnName,Label,InProduction,CustomizationLevel)
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')
--commit
--rollback

wrote Jul 6, 2010 at 11:17 AM

davideison wrote Feb 11, 2011 at 12:05 AM

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

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

with

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 9:55 AM

Hi all, where do I make this amend?

wrote Feb 14, 2013 at 2:59 AM