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)

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

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Mahendar Pal Profile Picture
    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.

  • Verified answer
    Justinjose Profile Picture
    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


  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator 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
    Inogic Profile Picture
    651 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!

  • Saddamk206 Profile Picture
    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

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
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans