Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Create Lead record from ASP.NET app

Posted on by Microsoft Employee

I'm trying to connect my custom ASP.NET app to Dynamics 365. On a form submit, the app should create a new Lead record in Dynamics. The app doesn't need to have users authenticated into CRM. I probably just need one default user which will take the form submit data and insert it into CRM.

My first attempt was to register an Azure app in Active Directory and add it's ID into my ASP.NET app so that it can connect to Dynamics. After the registration I tried to give it all possible permissions so that I can at least make it talk to Dynamics but it still had problems. I tried both Native and Web app, as shown in the screenshot.

But now I'm wondering if this is the way to go or am I way off?

KYS.png

*This post is locked for comments

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Create Lead record from ASP.NET app

    You will need add References to the Microsoft.Xrm.Sdk and Microsoft.Xrm.Tooling.Connector to your application, and have logic for connecting to your CRM environment. Within your asp.net application you have a couple of options to connect:

    // add the following in the Using section:

    using Microsoft.Xrm.Tooling.Connector;

    private IOrganizationService service;

    // Connect Using Connection String

    CrmServiceClient conn = new CrmServiceClient(connectionString);

    // Connect Using Credentials

    NetworkCredential creds = new NetworkCredential(userName, ConvertToSecureString(CRM_PASSWORD));

    AuthenticationType authType = AuthenticationType.Office365;

    CrmServiceClient conn = new CrmServiceClient(userName, ConvertToSecureString(CRM_PASSWORD), "NorthAmerica", orgName, isOffice365: true);

    // After creating the connection, you will need to map it to the Organization Service:

    service = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;

    // You can use the following function to ConvertToSecureString

           private static System.Security.SecureString ConvertToSecureString(string password)

           {

               if (password == null)

                   throw new ArgumentNullException("missing pwd");

               var securePassword = new System.Security.SecureString();

               foreach (char c in password)

                   securePassword.AppendChar(c);

               securePassword.MakeReadOnly();

               return securePassword;

           }

    Once you have the connection you can manipulate the CRM entities to create/retrieve information.

    Hope this helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Create Lead record from ASP.NET app

    My problem though is how to connect my app to Dynamics to insert the data. Do you have any tutorial how to use this SDK you are referring or the name of the SDK?

  • Suggested answer
    SavvyLuke Profile Picture
    SavvyLuke 655 on at
    RE: Create Lead record from ASP.NET app

    Micho,

    Give this link a try: http://colinvermander.com/2017/03/29/building-a-dynamics-365-asp-net-web-app-with-adoxio-connect-framework/

    It should help you get started.

  • Clem Profile Picture
    Clem 2,541 on at
    RE: Create Lead record from ASP.NET app

    Hello,

    Why don't you just use the SDK on your asp.Net site to parse the data submitted from your form and reuse it with the proper cast to create the record ?

    With some reflection you can easily rework the casting and you are then good to go.

    Clément

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans