locked
Add multiple contacts in one request? RRS feed

  • Question

  • I'm getting my feet wet with the CRM/XRM SDK and integrating with our existing LOB app.  One of the first tasks is to send thousands of contacts from our app to CRM.  I hate to take the hit of creating them one at a time, especially since we are using CRM Online.  Is there a way to send them all in one request?  I found how to add multiple members to a marketing list, but I don't see an equivalent request for creating contacts.  I'm thinking something along the lines of creating an EntityCollection and sending it all at once.  Or if that could be done, would the SDK create them one at a time behind the scenes anyway?

    I'd rather not import a file, but I will if it is the only option.  Now that I think about it, maybe sending thousands of records in a single request isn't a great idea.  I just need to be sure the import can be fully automated using the SDK, and that it supports adding new records and updating existing ones.  Any tips would be appreciated.

    Thanks,

    Joel

    Tuesday, July 3, 2012 11:04 PM

Answers

  • Contrary to the other posts, it is possible to create multiple records in one request, though this does involve a bit of schema manipulation, as you need a parent entity to attach the new contacts to. This article includes a bit more information.

    The 2 potential benefits to doing this in one request are performance (due to latency connecting to CRM Online), and having everything in one transaction. The drawbacks are the need for a schema change, and a bit more coding. You could potentially argue that sending in one transaction is a drawback, as you might want some records to complete


    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk


    Wednesday, July 4, 2012 8:33 AM
    Moderator
  • Via the SDK, one at a time is your only option.  If your data can be mapped via Data Import, that is without question the way that I would import it.  I resort to code only when the capabilities of the SDK and/or the complexity of the data require it.

    If you do decide to go with code, you can write it to be multi-thread to improve performance, but you are still limited to one Create per Request.  Read the following for what the SDK has to say on the matter:

    http://msdn.microsoft.com/en-us/library/gg509027.aspx#Performance


    --pogo (pat) @ pogo69.wordpress.com

    • Proposed as answer by Devashish Bajpai Wednesday, July 4, 2012 2:10 AM
    • Marked as answer by Joel Leach Thursday, July 5, 2012 2:36 PM
    Tuesday, July 3, 2012 11:28 PM

All replies

  • Via the SDK, one at a time is your only option.  If your data can be mapped via Data Import, that is without question the way that I would import it.  I resort to code only when the capabilities of the SDK and/or the complexity of the data require it.

    If you do decide to go with code, you can write it to be multi-thread to improve performance, but you are still limited to one Create per Request.  Read the following for what the SDK has to say on the matter:

    http://msdn.microsoft.com/en-us/library/gg509027.aspx#Performance


    --pogo (pat) @ pogo69.wordpress.com

    • Proposed as answer by Devashish Bajpai Wednesday, July 4, 2012 2:10 AM
    • Marked as answer by Joel Leach Thursday, July 5, 2012 2:36 PM
    Tuesday, July 3, 2012 11:28 PM
  • Hi,

    you can use this approach, you need to call create method under loop based on the number of contact, there is not way to create multiple records in one go. it will create record on by one only.

    Please don't forget to Vote and marked as answer If this post answers your question or was helpful, please click "Mark As Answer" on the post and "Mark as Helpful" Be wise

    Wednesday, July 4, 2012 6:14 AM
  • Contrary to the other posts, it is possible to create multiple records in one request, though this does involve a bit of schema manipulation, as you need a parent entity to attach the new contacts to. This article includes a bit more information.

    The 2 potential benefits to doing this in one request are performance (due to latency connecting to CRM Online), and having everything in one transaction. The drawbacks are the need for a schema change, and a bit more coding. You could potentially argue that sending in one transaction is a drawback, as you might want some records to complete


    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk


    Wednesday, July 4, 2012 8:33 AM
    Moderator
  • Thank you for the answers everyone.  I did some testing and throughput for creating the records one at a time is about 10 records per second.  That's not great, but it's not as bad as I thought it would be either. I will go with that or use multi-threading.
    Thursday, July 5, 2012 2:37 PM