Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

IOrganizationService.RetrieveMultiple

(0) ShareShare
ReportReport
Posted on by 10
Hello, help to make visual project studio C #, I need to export records of my entity Product.

Subsequently those records serialize them to XML.

I need an example.

This method is correct: IOrganizationService.RetrieveMultiple ???

I appreciate the support.

regards!

*This post is locked for comments

  • Arturo Nava Profile Picture
    Arturo Nava 10 on at
    RE: IOrganizationService.RetrieveMultiple

    Kokulan, I understand, I appreciate your help, thank you!

  • Verified answer
    Kokulan Profile Picture
    Kokulan 18,052 on at
    RE: IOrganizationService.RetrieveMultiple

    Hi Arturo

    CrmService in my example is just the variable name for OrganizationService, yes you are right its referring to the same IOrganizationService.RetrieveMultiple.

  • Arturo Nava Profile Picture
    Arturo Nava 10 on at
    RE: IOrganizationService.RetrieveMultiple

    Hello Kokulan,

    Thanks for answering ,,, Question..What is the difference between IOrganizationService.RetrieveMultiple vs. CrmService.RetrieveMultiple ????

    Is the same??

    I appreciate your support.

    regards!

  • Arturo Nava Profile Picture
    Arturo Nava 10 on at
    RE: IOrganizationService.RetrieveMultiple

    I appreciate your support Ravi, to be serialized.

    Do you have an example for RetriveMultiple ??

    Thanks for your support.

  • Arturo Nava Profile Picture
    Arturo Nava 10 on at
    RE: IOrganizationService.RetrieveMultiple

    Hello N.A.R.A, review and the RetrieveMultiple method, it is shown with _service.

    not with serviceProxy

    Regards!

  • Arturo Nava Profile Picture
    Arturo Nava 10 on at
    RE: IOrganizationService.RetrieveMultiple

    Hello N.A.R.A, I appreciate your help and time, I tell you to do what you send, ask, why does not show the method RetrieveMultiple ???

    What is the error?

    Regards!

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,052 on at
    RE: IOrganizationService.RetrieveMultiple

    Hi

    The following query will help you to retrieve products

    // Instantiate QueryExpression QEproduct

    var QEproduct = new QueryExpression("product");

    // Add columns to QEproduct.ColumnSet

    QEproduct.ColumnSet.AddColumns("name", "productid", "productnumber", "description", "statecode", "productstructure");

    QEproduct.AddOrder("productnumber", OrderType.Ascending);

    CrmService.RetrieveMultiple(QEproduct );

    If you are not familiar with building query using query expression, you can use the XrmToolBox Fetch XML builder as shown below

    01. Build your query in advance find and download the FETCH

    02. Paste your FETCH and Convert to Query Expression C# code as shown below

    1524.ScreenClip-_5B00_76_5D00_.png

    1524.ScreenClip-_5B00_76_5D00_.png

    Once you got the results, you can serialise or de-serialise as described in the link below

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/org-service/sample-serialize-deserialize-entity-instance

  • Verified answer
    N.A.R.A Profile Picture
    N.A.R.A 95 on at
    RE: IOrganizationService.RetrieveMultiple

    This is the example

    The result are entity collection, you can just convert to list of entity

    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Query;
    
    
    
    //This is how to connect
    
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    
    Uri crmOrganizationUri = new Uri("yourorganizationurl");
    var credentials = new ClientCredentials()
    {
    UserName = { UserName = "yourusername", Password = "yourpassword" }
    };
    var serviceProxy = new OrganizationServiceProxy(crmOrganizationUri, null, credentials, null);
    serviceProxy.EnableProxyTypes();
    if (impersonateGuid != default(Guid))
    {
    serviceProxy.CallerId = impersonateGuid;
    }
    
    
    
    //This is how to query
    
    QueryExpression productQe = new QueryExpression()
    {
    EntityName = "product",
    ColumnSet = new ColumnSet(true),
    Criteria = new FilterExpression()
    {
    //if you want add condition
    Conditions = { new ConditionExpression("name", ConditionOperator.Equal, "Arturo Nava") }
    }
    };
    EntityCollection productEc = serviceProxy.RetrieveMultiple(productQe);
    
    


    Good Luck 

  • Arturo Nava Profile Picture
    Arturo Nava 10 on at
    RE: IOrganizationService.RetrieveMultiple

    Hi, thanks for the serialize example, I already have it ...

    The problem I have is to connect to my organization and extract the products from the Product entity.

    help me

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 Moderator on at
    RE: IOrganizationService.RetrieveMultiple

    Hi,

    RetrieveMultiple message will return the collection of entity objects. Once retrieved you can use below sample to serielze it accordingly-

    docs.microsoft.com/.../sample-serialize-deserialize-entity-instance

    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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,430 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans