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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin : create a new record in an existing Entity

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Verified answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    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);


  • Community Member Profile Picture
    on at

    Thanks

  • Suggested answer
    Community Member Profile Picture
    on at

                               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);

                               }

  • Suggested answer
    Jeevarajan Kumar Profile Picture
    781 Most Valuable Professional on at

    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.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans