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)

need to create multiple records in dynamics crm

(0) ShareShare
ReportReport
Posted on by 76

Hello friends,

i want to create 100 records in custom entity using consle application with same data but the name should be changed. can any one please tell me how i can achieve this?

Thanks 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    Can the name be like   Sample Name 1, Sample Name 2... or does it have to be random names?

    You can create one entity object,  in a for loop you can loop through and change the name and create the records.

                   Entity entNewRecord = new Entity("new_customentity");

                   for (int i = 1; i <= 100; i++)

                   {

                       entNewRecord["new_name"] = "Sample Name 1" + i;

                       CrmService.Create(entNewRecord);

                   }

    In the above example, we are calling the CRM service 100 times.  if it is a one-off thing, you can call Service.Create 100 times not much of a performance issue to worry about.

    If you are planning to run this process on a regular or scheduled basis, you could consider using ExecuteMulitple to batch all the create requests into one. Please see below as to how you can do this

    // Create an ExecuteMultipleRequest object.
    var requestWithResults = new ExecuteMultipleRequest()
    {
       Settings = new ExecuteMultipleSettings()
    {
    ContinueOnError = false,
    ReturnResponses = true
    },
    Requests = new OrganizationRequestCollection()
    };

    // Loop 100 times and create 100 entity objects with different name and add it to the request collection

    for (int i = 1; i <= 100; i++)
    {
    Entity entNewRecord = new Entity("new_customentity");
    entNewRecord["new_name"] = "Sample Name 1" + i;

    CreateRequest createRequest = new CreateRequest { Target = entNewRecord };
    requestWithResults.Requests.Add(createRequest);
    }

    // Execute the batch request

    ExecuteMultipleResponse responseWithResults = (ExecuteMultipleResponse)CrmService.Execute(requestWithResults);

  • Suggested answer
    Hemanth Reddy.B Profile Picture
    76 on at

    Thanks Eswar

  • Kokulan Profile Picture
    18,054 on at

    Once you implemented and tested this, if this solved your problem, please mark the answer as verified so that other users with a similar issue might find this helpful.

    Thanks

  • gdas Profile Picture
    50,091 Moderator on at

    Hi,

    You can also use OOB import functionality without code.

  • Community Member Profile Picture
    on at

    How is this done Goutam?

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