Notifications
Announcements
No record found.
Hello,
In a c# plugin, i try to create a new record in an existing entity.
What is the code to do that ?
Thanks,
Paul
*This post is locked for comments
you need to instantiate first an IOrganizationService
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
and after create the record
Entity newAccount = new Entity("account"); newAccount["name"] = "TEST"; service.Create(newAccount);
Thanks
Entity goods = new Entity("goods");
goods .Attributes.Add("number", formNumber);
goods .Attributes.Add("comment", "");
goods .Attributes.Add("ownerid", owner);
try
{
Guid guid = Service.Create(goods);
}
catch (Exception e)
throw new InvalidPluginExecutionException("errors message\r\n" + e.Message, e);
Hi Paul,
Below links will help you to understand the plugin development.
Basics:
http://crmbook.powerobjects.com/extending-crm/plug-in-development-and-workflow-extensions/plug-ins/developing-a-plug-in/
In-depth about plug-in:
https://msdn.microsoft.com/en-us/library/gg334724.aspx
Develop using developer toolkit:
https://www.youtube.com/watch?v=v3vie4hSE80
Please mark this as answered if it is helpful.
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