web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans