How a .net Application can create a record in CRM contact table?
I have an existing .net 开发者_JAVA技巧web application that creates Customer contact record in regular SQL Server Database. Now we are migrating to CRM.
I am wondering from the .NET web application, what is the procedure to talk to CRM server and create a Contact record?
Thanks
As bjynito said, you want to look at the SDK, espescially helpful when starting out will be the Programming Reference
Here is a sample of creating a contact from a page in the programming ref.
// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Create the contact object.
contact contact = new contact();
// Create the properties for the contact object.
contact.firstname = "Jesper";
contact.lastname = "Aaberg";
contact.address1_line1 = "23 Market St.";
contact.address1_city = "Sammamish";
contact.address1_stateorprovince = "MT";
contact.address1_postalcode = "99999";
contact.donotbulkemail = new CrmBoolean();
contact.donotbulkemail.Value = true;
// Create the contact in Microsoft Dynamics CRM.
Guid contactGuid = service.Create(contact);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xrm.Client;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Client.Services;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string connectionString = "Url=https://orgname.crm5.dynamics.com; Username=adminusername@damnidiot.onmicrosoft.com; Password=your password;"; //configure this line
string value = "lllllllll";
AttributeCollection at = new AttributeCollection();
//at.Add("fullname",(String)value);
at.Add("firstname", (String)"LLLL1");
at.Add("lastname", (String)"ffff1");
Entity ent = new Entity();
ent.LogicalName = "contact";
ent.Attributes=at;
CrmConnection connection = CrmConnection.Parse(connectionString);
OrganizationService organisationservice = new OrganizationService(connection);
Guid g = organisationservice.Create(ent);
}}}
I think you've misunderstood (or I have) - CRM = Contact Relationship Management but doesn't imply a particular server/architecture
eg I write CRM software that uses a SQL Server back-end. If you can provide more information, we may be able to help futher
Recommend reading through the SDK. In particular, look at the articles on the web services and messages available.
精彩评论