India - D365-AX-CRM

Expand all | Collapse all

To get data of simple web form from external source to CRM system to create Lead record.

  • 1.  To get data of simple web form from external source to CRM system to create Lead record.

    Posted Apr 16, 2019 10:00 AM
    Hello CRM People,

    I do have a requirement that suppose there is a simple web page which has several fields just like Name, Contact No, Email Address, etc. & There is one submit button is available on that form when user clicks on that button after adding all those information then In CRM system the lead must be created then as soon as lead gets created then email notifications must be sent to someone that lead has been created and if lead does not get created then Email notification must be sent to another person that Lead has not been created when user submitted the data from that web page.

    Looking forward to see all of yours replies & Do let me know that how should i achieve this in Dynamics 365(CRM).


    Abdul Jabbar
    Techno Functional Consultant
    Navi Mumbai

  • 2.  RE: To get data of simple web form from external source to CRM system to create Lead record.

    Posted Nov 30, 2019 02:00 AM
    Hi Abdul,

    For above requirement, you can follow below steps:
    1. Create an ASP.Net Website .
    2. Create HTML Form with required field and Submit Button Functionality.
    3. On Submit button Event, you can call the below C# Code

      Entity leaddd = new Entity("lead");

      // Set the required attributes. For account, only the name is required.
      // See the Entity Metadata topic in the SDK documentation to determine
      // which attributes must be set for each entity.
      leaddd["firstname"] = "Abdul";
      leaddd["lastname"] = "Before Create Lead For Lead";
      leaddd["emailaddress1"] = "Before@CreateLeadForLead";
      leaddd["subject"] = "Before CreateLeadForLead";
      // Create an account record named Fourth Coffee.
      Guid id = service.Create(leaddd);

       Last line will return GUID if the lead is created in Dynamics 365 (CRM) other wise it will be NULL if not created.
    4. Now Create a workflow on Lead Create in Dynamics 365(CRM) to send the Mail for Successful Lead Creation Content. This workflow will trigger only after lead is created successful in the system so success scenario is handled here.
    5. For Failure scenario, you need to handle in the ASP.Net HTML page. If the GUID returned is NULL or Empty then send failure message from that page.

    This code explains how to send emails using C# in Dynamics 365 CRM.

    // Create the 'From:' activity party for the email            
    ActivityParty fromParty = new ActivityParty            
    PartyId = new EntityReference(SystemUser.EntityLogicalName, _userId)            };
    // Create the 'To:' activity party for the email
    ActivityParty toParty = new ActivityParty
    PartyId = new EntityReference("contact", _contactId) //Pass your required mail to record info
    // Create an e-mail message.
    Email email = new Email
    To = new ActivityParty[] { toParty },
    From = new ActivityParty[] { fromParty },
    Subject = "SDK Sample e-mail",
    Description = "SDK Sample for SendEmail Message.",
    DirectionCode = true
    _emailId = _serviceProxy.Create(email);

    I hope you have found a high level solution design for your need. Please feel free to reach out if more details/assistance is needed .

    Have a great day ahead.

    Thanks & Regards,

    Abhishek Dhoriya
    Dynamix Academy