locked
Status and State relationship in quotes RRS feed

  • Question

  • there is a relationship between the state and status of a quote. I can request and receive a list of statuscodes (StatusAttributeMetatData), but how can i tell which status codes are related to which state cdoes.

    for example, in a list i have retrieved there are two "In Progress" statuses (each with its OptionSet Value), one with the Draft State and one with the Open State. How can I tell which of the "In Progress" statuses is related to which State?

    Monday, January 2, 2012 4:02 PM

Answers

  • Hi

    biconix StatusAttributeMetatData.OptionSet.Options does not just return statuscode value. it also return some metadata information. The actual objects returned are called StatusOptionMetadata

    As I mentioned in my last post

    if you use the State property of the StatusOptionMetadata. it will return the statecode this statuscode belongs to

    it will return somwthing like 1,2

    if you want the label of this statecode like draft, active, won etc then use the StateAttributeMetadata request as you did  the StatusAttributeMetadata. Compare the value returned by the value obtained with StatusOptionMetadata.State and get the label of the matching value.

    I hope this helps.

     


    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
    • Proposed as answer by Amreek Singh Wednesday, January 4, 2012 10:40 PM
    • Marked as answer by biconix Thursday, January 5, 2012 11:01 AM
    Wednesday, January 4, 2012 10:40 PM

All replies

  • Which version of CRM are you using?  You go navigate to the Quote entity under "Settings > Customizations" in 4.0 and look at the relationships on the entity itself.
    http://radiateeverything.blogspot.com/
    Tuesday, January 3, 2012 8:34 PM
  • If I recall it correctly, if you retrieve the StatusAttributeMetatData.

    StatusOptionMetadata.State will give the state it belongs to(draft or active or won etc).

    try something like this

    foreach (StatusOptionMetadata statusMeta in 
        StatusAttributeMetatData.OptionSet.Options) //change the StatusAttributeMetatData with your variable name
    {
    // check the state here using StatusOptionMetadata.State

     

    }

    I hope this helps.

     


    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
    • Edited by Amreek Singh Wednesday, January 4, 2012 12:16 AM
    • Proposed as answer by Amreek Singh Wednesday, January 4, 2012 12:16 AM
    • Unproposed as answer by biconix Wednesday, January 4, 2012 4:47 PM
    Wednesday, January 4, 2012 12:15 AM
  • That is what I have been using, however, unless I am mistaken, StatusAttributeMetatData.OptionSet.Options returns the statuscode (Status Reason) values and not the statecode (Status) that the Status Reason is associated with

    Wednesday, January 4, 2012 4:52 PM
  • i am using 2011 and would like to do this programatically
    Wednesday, January 4, 2012 4:53 PM
  • Here is a utility function I wrote to retrieve a statecode on a related Status Code Value:

            /// <summary>
            /// Retrieve the State Code related to a given Status Code Value
            /// </summary>
            /// <param name="targetEntity">Generic Entity</param>
            /// <param name="statusCodeValue">Integer Status Code Value</param>
            /// <returns>State Code Option Set Value related to the given Status</returns>
            public OptionSetValue GetRelatedStateCode(Entity targetEntity, int statusCodeValue)
            {
                OptionSetValue stateCode = null;
                EntityMetadata targetMetadata = GetEntityMetadata(targetEntity);
                StatusAttributeMetadata sam = (from attrib in targetMetadata.Attributes
                                               where attrib.GetType() == typeof(StatusAttributeMetadata)
                                               select attrib).First() as StatusAttributeMetadata;
                OptionMetadata stdOption = (from optn in sam.OptionSet.Options
                                            where optn.Value == statusCodeValue
                                            select optn).First() as OptionMetadata;
                int stateOptionValue = (int)((StatusOptionMetadata)stdOption).State;
                stateCode = new OptionSetValue(stateOptionValue);
                return stateCode;
            }
    
    

     

    Wednesday, January 4, 2012 6:37 PM
  • Hi

    biconix StatusAttributeMetatData.OptionSet.Options does not just return statuscode value. it also return some metadata information. The actual objects returned are called StatusOptionMetadata

    As I mentioned in my last post

    if you use the State property of the StatusOptionMetadata. it will return the statecode this statuscode belongs to

    it will return somwthing like 1,2

    if you want the label of this statecode like draft, active, won etc then use the StateAttributeMetadata request as you did  the StatusAttributeMetadata. Compare the value returned by the value obtained with StatusOptionMetadata.State and get the label of the matching value.

    I hope this helps.

     


    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
    • Proposed as answer by Amreek Singh Wednesday, January 4, 2012 10:40 PM
    • Marked as answer by biconix Thursday, January 5, 2012 11:01 AM
    Wednesday, January 4, 2012 10:40 PM