Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Get label of a CRM field

Posted on by

Hi,

It is possible to get the label of optionsets in CRM. For following optionset, I would like to get the value of Label.

Label: Dryer

Schema name: new_dryer

OptionSet Name: Working

OptionSetValue: 970200001

*This post is locked for comments

  • Jorge S Profile Picture
    Jorge S on at
    RE: Get label of a CRM field

    I do have the schema name of the option set, and I would like to get label of the option set.

  • Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Get label of a CRM field

    Okay , so are you saying you need to extract the value based on label?

  • Jorge S Profile Picture
    Jorge S on at
    RE: Get label of a CRM field

    Hi,

    thanks for your reply. I do use following code, but it gives me back Working which is the label of the value. 

    RetrieveAttributeRequest raRequest = new RetrieveAttributeRequest
                {
                    EntityLogicalName = "new_visit",
                    LogicalName = "aux_dryer",
                    RetrieveAsIfPublished = true
                };
    
                RetrieveAttributeResponse raResponse = (RetrieveAttributeResponse)service.Execute(raRequest);
                PicklistAttributeMetadata paMetadata = (PicklistAttributeMetadata)raResponse.AttributeMetadata;
                OptionMetadata[] optionList = paMetadata.OptionSet.Options.ToArray();
    
                Dictionary<int, string> dic = new Dictionary<int, string>();
                foreach (OptionMetadata oMD in optionList)
                {
                    return oMD.Label.LocalizedLabels.Where(x => x.LanguageCode == 1033).FirstOrDefault().Label.ToString();
                    //dic.Add((int)oMD.Value, oMD.Label.LocalizedLabels.Where(x => x.LanguageCode == 1033).FirstOrDefault().Label.ToString());
                }
                return "";


  • Verified answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Get label of a CRM field

    Hello there,

    You will have make request to crm metadata , have a look here :

    c# :community.dynamics.com/.../retrieve-option-set-metadata-in-c

    JS : nishantrana.me/.../retrieve-optionset-label-using-sdk-metadata-rertrieveattribute-method-in-javascript-crm-2011  

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans