How to create account in dynamics crm using asp net

Introduction

ASP.NET is a popular language used for developing web applications. In this article, we will explore how to create an in Dynamics CRM using ASP.NET. Dynamics CRM is a relationship management software developed by Microsoft.

Prerequisites

Before we begin, make sure you have the following:

  • Studio installed on your machine
  • An Dynamics CRM account

Step 1: Setting up the Project

First, let's create a new ASP.NET project in Visual Studio. Follow :

  1. Open Visual Studio and click on “Create a new project”.
  2. Select “ASP.NET Web Application” and a suitable project name and location.
  3. Choose the “Empty” template and make sure to check the “Web Forms” checkbox.
  4. Click on “Create” to create the project.

Step 2: References

In order to interact with Dynamics CRM, we need to add the necessary references to our project. Follow these steps:

  1. Right-click on the project in the Solution Explorer and select “Manage NuGet Packages”.
  2. In the NuGet Package Manager, search for “Microsoft.CrmSdk.CoreAssemblies” and install it.
  3. Once the installation is complete, we can proceed to the next step.

Step 3: Writing the Code

Now, let's write the code to create an account in Dynamics CRM. Insert the following code in your ASP.NET project:


using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Tooling.Connector;

public void CreateAccount()
{
    // Connect to Dynamics CRM
    CrmServiceClient service = new CrmServiceClient("AuthType=Office365;Url=https://yourcrmurl.crm.dynamics.com;Username=yourusername;Password=yourpassword");

    // Create an account entity
    Entity account = new Entity("account");
    account["name"] = "Sample Account";
    account["address1_city"] = "New York";
    account["address1_country"] = "United States";

    // Save the account entity
    service.Create(account);
}

Make sure to replace “yourcrmurl”, “yourusername”, and “yourpassword” with your actual Dynamics CRM URL, username, and password.

Step 4: Calling the Method

Finally, let's call the “CreateAccount” method to create the account. You can call this method in the Page_Load event or any other suitable event in your ASP.NET application.


protected void Page_Load(object sender, EventArgs e)
{
    CreateAccount();
}

Conclusion

In this article, we have learned how to create an account in Dynamics CRM using ASP.NET. By following the steps and writing the provided code, you can easily Dynamics CRM functionality into your ASP.NET web application.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents