Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7768447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:54:57+00:00 2026-06-01T15:54:57+00:00

Within Dynamics CRM the Lead entity has both a Status and a Status Reason.

  • 0

Within Dynamics CRM the Lead entity has both a Status and a Status Reason. Using the API I can get all of the Status Reasons. Where I am getting tripped up is when my user selects a Status Reason I would like to work backwards and figure out which Status is associated with the selected Status Reason.

Here is how I get all of the Status Reasons:

 //get the list of status reasons 
 RetrieveAttributeRequest request = new RetrieveAttributeRequest();
 request.EntityLogicalName = "lead";
 request.LogicalName = "statuscode";

 RetrieveAttributeResponse response = RetrieveAttributeResponse)theOrgContext.Execute(request);
StatusAttributeMetadata picklist = (StatusAttributeMetadata)response.AttributeMetadata;
 foreach (OptionMetadata option in picklist.OptionSet.Options)
 {
  retval.ListOfStatuses.Add(option.Value.Value, option.Label.UserLocalizedLabel.Label.ToString());
 }

And To update an entity I am just using LINQ:

 //set the status to the new value
 theLead.StatusCode.Value = int.Parse(statusValue);

theLead.StateCode = ???

//mark the object as updated
theContext.UpdateObject(theLead);

//persist the changes back to the CRM system
theContext.SaveChanges();

I just can’t figure out how to query CRM to figure out what value I would need to put in for the ???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:54:58+00:00Added an answer on June 1, 2026 at 3:54 pm

    You can retrieve the information for state with status.

    RetrieveAttributeRequest req = new RetrieveAttributeRequest();
    req.EntityLogicalName = "lead";
    req.LogicalName = "statuscode";
    req.RetrieveAsIfPublished = true;
    RetrieveAttributeResponse res = (RetrieveAttributeResponse)yourContext.Execute(req);
    
    StatusAttributeMetadata attribute = (StatusAttributeMetadata)res.AttributeMetadata;
    foreach (StatusOptionMetadata oStatusOptionMetaData in attribute.OptionSet.Options)
    {
        var state = oStatusOptionMetaData.State.Value;
        var status = oStatusOptionMetaData.Value.Value;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to get the dynamic select results of EXECUTE within PL/SQL from Oracle sqlplus
Within the scope of a Rails controller or a view: How can I query
i trying to add some costume app into Dynamics CRM basically i have an
I found some sample code in Microsoft Dynamics CRM 4.0 SDK which is asking
When using HP-UX I can use the chatr utility to report on various internal
I have a Microsoft Dynamics CRM 4.0 form with an IFRAME on it that
We offer multiple packages with features for our clients with Microsoft Dynamics CRM. Is
I have created dynamic pricing forms within a e-commerce site using javascript and it
Does anyone implement Dynamics CRM claims based authentication utilizing existing STS? White paper says:
How can I add dynamic and unique, CSS ID, within a cycle with haml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.