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)

creating multiple record of an existing entity

(0) ShareShare
ReportReport
Posted on by

I have an array of records in plugin code  , and I want to create multiple record iterating through the array , how can I write plugin to store multiple records in existing entity.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hi,

    Assuming you have array that you want to use to create custom entity record ? if yes you can loop through the length of the array and can use create method for your entity something like this

    for(int i=0; i<array.Lenght; i++)

    {

    Entity customEntity=new Entity("your entityname");

    customEntity["yourcustomentityfield"]=array[i]; //you need different syntax for different data type

    crmservice.Create(customEntity);

    }

    Please check SDK for more details, let me know if my understanding is not correct.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    Keep in mind there is no use of Executemultiple request in plugin, as plugin use executemultiple request internally in case your plugin runs under transactions.

  • Community Member Profile Picture
    on at

    my custom entity is child entity of opportunity , so do I have to define relationship also in plugin?

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    Yes, for child records you need to set entity reference like below

    customEntity[“referencefieldname”]=new EntityReference(“opportunity”,entity.id);

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