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)

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

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

  • Arturo Nava Profile Picture
    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

  • Verified answer
    N.A.R.A Profile Picture
    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 

  • Suggested answer
    Kokulan Profile Picture
    18,054 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

  • Arturo Nava Profile Picture
    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!

  • Arturo Nava Profile Picture
    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
    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
    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!

  • Verified answer
    Kokulan Profile Picture
    18,054 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
    10 on at
    RE: IOrganizationService.RetrieveMultiple

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

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
UllrSki Profile Picture

UllrSki 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans