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.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
JS-09031509-0 3
AS-17030037-0 2
Mark Eckert 2