Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

multi selection working with C#

Posted on by Microsoft Employee

Hi

I am interested in finding a way through C# to extract the array made from the multi selection to its values and fetching entity data accordingly

for example if the array include names - to fetch all contacts with these names

would appreciate any help

*This post is locked for comments

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: multi selection working with C#

    Hi,

    You can use the "In" operator and pass the array. Sample below-

    ======================

    using (service = new OrganizationServiceProxy(new Uri(_organizationURI), null, _credential, null))

               {

                   var contactNames = new string[] { "Jim", "James" };

                   QueryExpression query = new QueryExpression("contact");

                   query.ColumnSet = new ColumnSet(true);

                   query.Criteria.AddCondition("firstname", ConditionOperator.In, contactNames);

                   var results = service.RetrieveMultiple(query);

                   foreach (var contact in results.Entities)

                   {

                       Console.WriteLine(contact["fullname"]);

                   }

               }

    ======================

    Hope this helps.

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans