Skip to main content

Create Lead CRM 2011 online using Webservice and Html 5 responsive Page



Hi Guys


I am writing a new Article which is quite interesting, I use CRM 2011 Online version first time and got an idea, if we connect our company website contact us page to CRM Lead then we can improve our sale


Here is the Example which I create Lead in CRM through simple asp.net website. I design this website to HTML 5 so, Website can open in any browser any mobile any tablet .I have tested in multiple Mobile Sets. This is best example of responsive application


 Web Version








Mobile Version




How to Work?







Back End Code
 
Hi Guys
I am writing a new Article which is quite interesting, I use CRM 2011 Online version first time and got an idea, if we connect our company website contact us page to CRM Lead then we can improve our sale
Here is the Example which I create Lead in CRM through simple asp.net website. I design this website to HTML 5 so, Website can open in any browser any mobile any tablet .I have tested in multiple Mobile Sets. This is best example of responsive application

Web Version

Mobile Version
How to Work?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Sdk;
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Client;
using System.Net;
public partial class _Default : System.Web.UI.Page
{
OrganizationServiceProxy organizationProxy;
protected void Page_Load(object sender, EventArgs e)
{
organizationProxy = this.ReturnCRMServiceInstance();
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
Entity _Lead = new Entity("lead");
_Lead["firstname"] = FirstName.Text.ToString();
_Lead["subject"] = "Dynamics CRM 2011 Leads";
_Lead["lastname"] = LastName.Text.ToString();
_Lead["emailaddress1"] = EmailAddress.Text.ToString();
_Lead["address2_telephone1"] = Telephone.Text.ToString();
organizationProxy.Create(_Lead);
FirstName.Text = string.Empty;
LastName.Text = string.Empty;
EmailAddress.Text = string.Empty;
Telephone.Text = string.Empty;
}
catch (Exception ex)
{
}
finally
{
organizationProxy.Dispose();
}
}
public OrganizationServiceProxy ReturnCRMServiceInstance()
{
String organizationUri = "https://lflgeneve.crm4.dynamics.com/XRMServices/2011/Organization.svc";
IServiceManagement<IOrganizationService> OrganizationServiceManagement = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri(organizationUri));
AuthenticationProviderType OrgAuthType = OrganizationServiceManagement.AuthenticationType;
AuthenticationCredentials authCredentials = GetCredentials(OrgAuthType);
AuthenticationCredentials tokenCredentials = OrganizationServiceManagement.Authenticate(authCredentials);
OrganizationServiceProxy organizationProxy;
SecurityTokenResponse responseToken = tokenCredentials.SecurityTokenResponse;
using (organizationProxy = new OrganizationServiceProxy(OrganizationServiceManagement, responseToken))
{
organizationProxy.EnableProxyTypes();
}
return organizationProxy;
}
private AuthenticationCredentials GetCredentials(AuthenticationProviderType endpointType)
{
//string discoveryServiceAddress = "https://disco.crm4.dynamics.com/XRMServices/2011/Discovery.svc"; //Use this discovery URL
//string organizationUniqueName = "lflgeneve"; //Provide the unique name of the organization
string userName = "ITUSER@lflgeneve.onmicrosoft.com"; //Use your office 365 user Id
string password = "1234@abcd"; //Provide your password here
string domain = "onmicrosoft";
 
AuthenticationCredentials authCredentials = new AuthenticationCredentials();
switch (endpointType)
{
case AuthenticationProviderType.ActiveDirectory:
authCredentials.ClientCredentials.Windows.ClientCredential =
new System.Net.NetworkCredential(userName, password, domain);
break;
case AuthenticationProviderType.LiveId:
authCredentials.ClientCredentials.UserName.UserName = userName;
authCredentials.ClientCredentials.UserName.Password = password;
authCredentials.SupportingCredentials = new AuthenticationCredentials();
//authCredentials.SupportingCredentials.ClientCredentials = DeviceIdManager.LoadOrRegisterDevice();
break;
default: // For Federated and OnlineFederated environments.
authCredentials.ClientCredentials.UserName.UserName = userName;
authCredentials.ClientCredentials.UserName.Password = password;
break;
}
return authCredentials;
}
 
}

Comments