Notifications
Announcements
No record found.
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
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.
Hi Shristi ,
You can also try with ExecuteMultiple -
msdynamicscrmblog.wordpress.com/.../use-executemultiplerequest-for-bulk-createupdatedelete-using-c-in-dynamics-crm-2011-2
msdn.microsoft.com/.../jj863631.aspx
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.
my custom entity is child entity of opportunity , so do I have to define relationship also in plugin?
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2