Hi pals,I'm trying to create a contact record in MSCRM2011 online using an external web page.I couldn't find Microsoft.CRM.Service.Utility dll from sdk. can any body help me..
Thanks ... :)
using System;using Microsoft.Crm;
using Microsoft.Crm.Tools;
using System.Net;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Services.Utility; // * Did not referenced
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Client;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Web.Services;
public partial class crm_contact : System.Web.UI.Page
{
private static ClientCredentials GetDeviceCredentials()
{
return Microsoft.Crm.Services.Utility.DeviceIdManager.LoadOrRegisterDevice();
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
{
//Authenticate using credentials of the logged in user;
ClientCredentials Credentials = new ClientCredentials();
//Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
Credentials.UserName.UserName = "users.onmicrosoft.com";
Credentials.UserName.Password = "Pass1";
//This URL needs to be updated to match the servername and Organization for the environment.
Uri OrganizationUri = new Uri("https://******.api.crm5.dynamics.com/XRMServices/2011/Organization.svc");
Uri HomeRealmUri = null;
//OrganizationServiceProxy serviceProxy;
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri,Credentials,GetDeviceCredentials()))
{
serviceProxy.EnableProxyTypes();
IOrganizationService service = (IOrganizationService)serviceProxy;
//Instantiate the contact object and populate the attributes.
Entity contact = new Entity("contact");
contact["firstname"] = txtFirstName.Text.ToString();
contact["lastname"] = txtLastName.Text.ToString();
contact["emailaddress1"] = txtEmailAddress.Text.ToString();
contact["telephone1"] = txtPhoneNumber.Text.ToString();
Guid newContactId = service.Create(contact);
//This code will clear the textboxes after the contact is created.
txtFirstName.Text = "";
txtLastName.Text = "";
txtEmailAddress.Text = "";
txtPhoneNumber.Text = "";
}
}
}
}