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 365 | Integration, Dataverse...
Suggested Answer

want development using c sharp and javascript for D365

(1) ShareShare
ReportReport
Posted on by 2
want development using c sharp and javascript for D365
Hi am keen to use Visual Studio c# and JavaScript with D365. Is there other topics I need to know ?
Can you give me a business scenario where you have used c# and JavaScript and how you over come this ?
Say e.g when a new account is registered it also needs to create a customer record so here a plugin needs to be created,
I am a very good coder creating all sort of code on platform but am a novice in using d365.
Are there good resources out there ?
I cant seem to get round my head where I can use a scenario and getting bored reading
Categories:
I have the same question (0)
  • Suggested answer
    Saif Ali Sabri Profile Picture
    2,354 Moderator on at
    1. Key Topics to Learn for D365 Development
    Beyond C# and JavaScript, focus on:
    • D365 Platform Fundamentals: Common Data Model, Dataverse, and entity relationships.
    • Plugins (C#): Server-side logic triggered by events (e.g., record creation/update).
    • Client-Side Scripting (JavaScript): Form events (e.g., OnSaveOnChange), UI interactions.
    • Web Resources: HTML/CSS/JavaScript files embedded in D365.
    • Power Automate: Low-code workflows for integration with plugins/scripts.
    • Tools: Plugin Registration Tool, XrmToolBox, and browser DevTools for debugging.

    2. Business Scenario: Automated Customer Record Creation
    Requirement:
    When a new Account is created in D365, automatically generate a related Contact record as the primary customer and validate the account’s email format.

    Implementation Steps
    a. JavaScript (Client-Side Validation):
    • Purpose: Validate the email format on the Account form before saving.

    • Code Example:

      javascript
      Copy
      function validateEmail(executionContext) {
        const formContext = executionContext.getFormContext();
        const email = formContext.getAttribute("emailaddress1").getValue();
        const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
      
        if (!regex.test(email)) {
          alert("Invalid email format!");
          executionContext.getEventArgs().preventDefault(); // Block save
        }
      }
    • How to Attach: Use the Account form’s OnSave event.
       

      b. C# Plugin (Server-Side Automation):

    • Purpose: Create a Contact record when a new Account is saved.

    • Code Example:

      csharp
      Copy
      public class AutoCreateContactPlugin : IPlugin
      {
          public void Execute(IServiceProvider serviceProvider)
          {
              IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
              IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
              IOrganizationService service = factory.CreateOrganizationService(context.UserId);
      
              if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity account)
              {
                  Entity contact = new Entity("contact");
                  contact["firstname"] = account.GetAttributeValue<string>("name");
                  contact["lastname"] = "Primary Customer";
                  contact["parentcustomerid"] = new EntityReference("account", account.Id);
                  service.Create(contact);
              }
          }
      }
    • Registration: Deploy using the Plugin Registration Tool (trigger on Create of Account).


    • 3. Challenges & Solutions

    • Infinite Loops:
      • Issue: A plugin updating an Account could retrigger itself.
      • Fix: Use a flag (e.g., a custom field) to check if the action is already processed.
    • Async vs. Sync:
      • Use synchronous plugins for real-time actions (e.g., validation). Use async for non-critical tasks (e.g., sending emails).
    • Debugging:
      • Use Plugin Trace Logs and browser DevTools for JavaScript debugging.
        4. Learning Resources
    • Microsoft Learn:
    • Tools:
    • Community:
      • YouTube: Dynamics Chronicles, Power Platform Academy.
      • GitHub Repos: Microsoft Dynamics 365 samples, D365-Programming-Samples.

    • 5. Next Steps
    • Build a simple plugin + JavaScript project (e.g., auto-populate fields).
    • Experiment with the Dataverse Web API for CRUD operations.
    • Explore Power Automate to complement plugins (e.g., approval workflows).
    • By combining C# plugins (server-side) and JavaScript (client-side), you can automate complex business logic while ensuring a seamless user experience. Start small, test iteratively, and leverage the D365 community!
       

       

       

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 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 174

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 62 Super User 2026 Season 1

#3
ManoVerse Profile Picture

ManoVerse 52 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans