web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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

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

  • Verified answer
    Justinjose Profile Picture
    2,707 on at

    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

    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
    709 on at

    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

    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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans