1
votes

In Microsoft Dynamics CRM 4.0, I want to be able to check if a record of any entity type is disabled. I think I can check the statecode. From the information I have seen, a value of zero means that the entity is enabled (editable in CRM) and any other value means disabled (for editing in CRM).

Is this assumption correct for all entities?

EDIT

If my assumption is correct, is it possible to create a QueryExpression for dynamic entities that does such a comparison, rather than using the text, "Active", which would be incorrect for quotes?

1

1 Answers

0
votes

From what I've read, StateCode is not necessarily the same for every entity. It varies per entity.

I'm not aware of a way to disable an entity. I double checked our install, but don't see any option to disable. Google also yields no results to this end.

Do you mean perhaps individual entity records? If so, you'll have to check the StateCode for the entity you're looking at. I think most entities use StateCode as you describe, but for some entities, such as Activities, it seems to vary a little.

Here is some SQL I found to pull back the StateCode/StatusCode details of a particular entity:

select 
    AttributeName, 
    AttributeValue,
    Value
from dbo.StringMap 
where
(dbo.StringMap.AttributeName = 'statuscode' 
or
dbo.StringMap.AttributeName = 'statecode')
and 
dbo.StringMap.ObjectTypeCode = 1

ObjectTypeCode 1 maps to the Account entity.

Hope this helps.

EDIT: Just saw your addition. I think you'll be safe using StateCode in most instances. I personally use it in one of my projects to exclude disabled records on the Lead and Contact entities. Just double check the value mapping as I've described and then implement.