// sample to test the method
private void CreateAccount(string AccountName)
{
IOrganizationService _service = GetCRMService("http://<ServerName>:<PortNumber>", "<UserName>", "<Password>", "<Domain>");
try
{
Entity account = new Entity("account");
account["name"] = AccountName;
_service.Create(account);
}
catch (Exception ex)
{
throw;
}
}
// GetCRMService
public static IOrganizationService GetCRMService(string ServerURL, string UserName, string Password, string DomainName)
{
ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = new System.Net.NetworkCredential(UserName, Password, DomainName);
Uri organizationUri = new Uri(ServerURL + "/<OrgName>/XRMServices/2011/Organization.svc");
Uri homeRealmUri = null;
OrganizationServiceProxy orgService = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
IOrganizationService _service = (IOrganizationService)orgService;
return _service;
}
How to Assign Custom GUid to Entity when creating entity in MS CRM 2011 using service
ReplyDelete