Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Web Form to Dynamics CRM 4

We've decided to release another component we've been using internally. This little webcontrol allows you put pass data from a Web Form to Dynamics CRM 4.

How does it work?
Create a UserControl to layout the form.

<%@ Control Language="C#" %>
Topic:
<asp:TextBox ID="topic" runat="server" /><br />
First Name:
<asp:TextBox ID="firstname" runat="server" /><br />
Rating:
<asp:DropDownList ID="rating" runat="server">
<asp:ListItem Text="Hot" Value="1"></asp:ListItem>
<asp:ListItem Text="Warm" Value="2"></asp:ListItem>
<asp:ListItem Text="Cold" Value="3"></asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:Button ID="submit" runat="server" Text="Add to CRM" />
Next we add the Web2EntityControl into our .aspx page and configure the connection settings (Url, Username, Password, Domain ...etc of CRM) as well as Mappings.
For example:
Which field in Dynamics CRM should the topic field (from above) map to?

Here is a sample configration
<magnetism:Web2EntityControl ID="leadform" runat="server" SkinPath="~/lead.ascx"
Async="true">
<Settings Url="http://virtualcrm/mscrmservices/2007/crmservice.asmx"
Domain="MAGNETISM" OrganizationName="Demo" UserName="Administrator"
Password="itsasecret" EntityName="lead" />
<Mappings>
<magnetism:Mapping CrmFieldSchemaName="subject" CrmFieldType="NVarChar"
ControlID="topic" ValuePropertyName="Text" />

<magnetism:Mapping CrmFieldSchemaName="firstname" CrmFieldType="NVarChar"
ControlID="firstname" ValuePropertyName="Text" />

<magnetism:Mapping CrmFieldSchemaName="leadqualitycode" CrmFieldType="Picklist"
ControlID="rating" ValuePropertyName="SelectedValue" />
</Mappings>
</magnetism:Web2EntityControl>
This form is mapped to the Lead entity (EntityName="lead")
Topic textbox is mapped to the "subject" field in Dynamics CRM
First Name textbox is mapped to "firstname" field in CRM
Rating dropdownlist is mapped to "leadqualitycode" picklist in Dynamics CRM

This control works with On-Premise, Partner Hosted & IFD installations. This works really well for data entry forms, we use it on our Contact Us page as well as client contact us pages and hand the data through to leads or cases depending on the customer query.

If you'd like a copy contact me.

Enjoy!

2 Comments

Comments have been disabled for this content.