0
votes

I tried running this Query in CRM 2011:

var activity = (from a in crmService.ActivityPointerSet
                where a.StateCode == ActivityPointerState.Open &&
                      a.ActivityTypeCode == "4201"
                select a).First();

But I got this error:

Microsoft.Crm.Metadata.EntityMetadataNotFoundException: The entity with a name = '4201' was not found in the MetadataCache

After checking with the FilteredActivityPointer database view, I noticed that that column was defined as an int, not a string. I manually edited the generated class, changing the string to an int on the property, and it worked just fine.

Is there a bug in the early bound type generator (CrmSvcUtil.exe), or did I somehow create it wrong?

EDIT: After some more testing, it looks like the ActivityTypeCode is expecting the string "appointment". Don't know why it's showing differently in the database though...

1

1 Answers

2
votes

I would imagine they have done this as ObjectTypeCodes are not guaranteed to be the same across different deployments (if you have more than one).

By using 'task', 'appointment' or 'email' (etc) there is no ambiguity.

I agree it seems a bit strange though!