web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Determine which entity's Status is Active or Inactive

(0) ShareShare
ReportReport
Posted on by

Hello,

I faced a situation, when I need to know if CRM Entity is active or inactive.

For e.g. you can check type of form if it is Read Only, when you performing actions in Form itself.

But what to do if you have retrieved record (in  plugin) and know only the Status?

 Is it possible to know from Status if record is editable?

Thanks for answers,

povversas

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Determine which entity's Status is Active or Inactive

    Hi ,

    You can get the status of the records (i.e active or inactive) in plugin with the help of the below code.

    var cols = new ColumnSet(new[] { "statecode", "statuscode" });

    var entity = organizationService.Retrieve(entityName, recordId, cols);

    var Status=entity.GetAttributeValue<OptionSetValue>("statecode").Value;

    the code retrieves the value of the status. Mostly for Active it will be "0" and Inactive "1"

  • povversas Profile Picture
    on at
    RE: Determine which entity's Status is Active or Inactive

    Thanks for quick reply.

    Refering to "Mostly for Active it will be "0" and Inactive "1"", i am not happy with mostly.

    This means i have to hard code exceptions, where 0 does not refer to Active Status, for. e.g. Case(incident) entity.

    It has 3 Statuses: Open, Resolved, Canceled. What I want is to get answer like this:

    Open - > you can edit

    Resolved- > you can NOT edit

    Canceled- > you can NOT edit.

    Is it posible?

     

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Determine which entity's Status is Active or Inactive

    Hi,

    You can use advance find to get the status values of the record.

    In advance find check the status is equal to resolved then fetch the XML. In the XML you can get the status value.

    For example the xml for case resolved:

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">

     <entity name="incident">

       <attribute name="prioritycode" />

       <attribute name="ticketnumber" />

       <attribute name="title" />

       <attribute name="createdon" />

       <attribute name="statecode" />

       <attribute name="incidentid" />

       <order attribute="title" descending="false" />

       <filter type="and">

         <condition attribute="statecode" operator="eq" value="1" />

       </filter>

     </entity>

    </fetch>

    In case of resolve the status value is 1.

  • Suggested answer
    Royal King Profile Picture
    27,686 on at
    RE: Determine which entity's Status is Active or Inactive

    check the below post it gives state and status code of all the entity in CRM. Like Archana specified most of the entity as value "0" for active and "1" deactive  except list of system entities that has different values. You need to retrieve state and status code of entity to verify status of the record.

    msdynamicscrmblog.wordpress.com/.../status-and-status-reason-values-in-dynamics-crm-2013

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans