Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to retrieve multi select option set field from crm using C#?

Posted on by Microsoft Employee

Hello all!

How do I retrieve multi select option set field from crm using C#?

I tried this but it doesn't seem to work and it's a bit too advanced to me to debug.

http://www.itaintboring.com/dynamics-crm/dynamics-365-v9-multi-select-option-sets-c-and-sdk-versioning/

Can anyone show me how it's done?

Thank you!

*This post is locked for comments

  • Saddamk206 Profile Picture
    Saddamk206 777 on at
    RE: How to retrieve multi select option set field from crm using C#?

    Hi,

    Please try this:-

    http://saddamk.blogspot.com/2018/09/insert-and-get-value-in-multiselect.html

  • Verified answer
    Inogic Profile Picture
    Inogic 24,094 on at
    RE: How to retrieve multi select option set field from crm using C#?

    You have to use latest 9.0 SDK dll i.e (include refer Microsoft.Crm.Sdk.Proxy.dll and Microsoft.Xrm.Sdk.dll in your c# Project)

     

    To get 9.0 sdk from nuget use this link.

     

    By using below code you will get the collection from MultiSelect Option set as shown in below screen shot:

    6082.Sdk.jpg

    Thanks!

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: How to retrieve multi select option set field from crm using C#?

    Hi Heimmu,

    The article that was written by Alex Shlega was to provide the ability to query multiselect optionsets prior to the availability of the SDK, which contains the OptionSetValueCollection collection. Building it at this point, while the SDK provides you with that functionality is completely unnecessary.

    At this point, you can use:

    OptionSetValueCollection ovc = (OptionSetValueCollection)result["new_myOptionset"];

    This will return the Collection of Values in the OptionSet.

    You can the loop through the values in the collection to retrieve the individual values.

    Hope this helps.

  • Verified answer
    Justinjose Profile Picture
    Justinjose 2,707 on at
    RE: How to retrieve multi select option set field from crm using C#?

    Hi Heimmu,

    try something like this

    QueryExpression queryAccount = new QueryExpression();
                queryAccount.EntityName = EntityName;
                queryAccount.ColumnSet.Columns.Add("new_multiselectoptionset");
                queryAccount.Criteria.AddCondition("name", ConditionOperator.Equal, "account name");
                EntityCollection ec = _orgService.RetrieveMultiple(queryAccount);
                foreach (var item in ec.Entities)
                {
                    OptionSetValueCollection op= (OptionSetValueCollection)item["new_multiselectoptionset"];
                    foreach (var options in op)
                    {
                      int i =  options.Value;
    
                    }
    
                }

    Thanks

    Justin Jose


  • Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: How to retrieve multi select option set field from crm using C#?

    You share your code here so someone can look into that.

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