creating primary keys in microsoft dynamics crmHi,<br/>I wanted to know how to create primary key attributes for custom entities in microsoft dynamics crm.© 2009 Microsoft Corporation. All rights reserved.Mon, 29 Jun 2009 14:26:03 Z0cee5411-f480-4a86-b5b4-44fac66db268http://social.msdn.microsoft.com/Forums/en-US/sqldatamining/thread/0cee5411-f480-4a86-b5b4-44fac66db268#0cee5411-f480-4a86-b5b4-44fac66db268http://social.msdn.microsoft.com/Forums/en-US/sqldatamining/thread/0cee5411-f480-4a86-b5b4-44fac66db268#0cee5411-f480-4a86-b5b4-44fac66db268princess_mehttp://social.msdn.microsoft.com/Profile/en-US/?user=princess_mecreating primary keys in microsoft dynamics crmHi,<br/>I wanted to know how to create primary key attributes for custom entities in microsoft dynamics crm.Tue, 26 May 2009 09:42:20 Z2009-05-26T09:42:20Zhttp://social.msdn.microsoft.com/Forums/en-US/sqldatamining/thread/0cee5411-f480-4a86-b5b4-44fac66db268#6fb52e71-bb85-4f96-9903-7675c5193896http://social.msdn.microsoft.com/Forums/en-US/sqldatamining/thread/0cee5411-f480-4a86-b5b4-44fac66db268#6fb52e71-bb85-4f96-9903-7675c5193896Scott Sewell, CustomerEffectivehttp://social.msdn.microsoft.com/Profile/en-US/?user=Scott%20Sewell%2c%20CustomerEffectivecreating primary keys in microsoft dynamics crmThe unique key is automatically created for you when you create a custom entity - new_customentitynameID - it's a guid. - <br/><br/>Adding other attributes is done through the CRU administration UI.<hr class="sig">Scott Sewell, CustomerEffective | http:\\blog.CustomerEffective.com | Twitter:@ScottSewellMon, 29 Jun 2009 10:49:44 Z2009-06-29T10:49:44Zhttp://social.msdn.microsoft.com/Forums/en-US/sqldatamining/thread/0cee5411-f480-4a86-b5b4-44fac66db268#a6567884-b76b-4156-9767-299b77e9f71chttp://social.msdn.microsoft.com/Forums/en-US/sqldatamining/thread/0cee5411-f480-4a86-b5b4-44fac66db268#a6567884-b76b-4156-9767-299b77e9f71cprincess_mehttp://social.msdn.microsoft.com/Profile/en-US/?user=princess_mecreating primary keys in microsoft dynamics crmthanks.. that was of great help.... I wanted to know how to access crm web services from an aspx page... i tried to execute the following code given as example in the crmsdk.chm file<br/><br/> <pre lang=x-aspx>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.Crm.Sdk; using Microsoft.Crm.SdkTypeProxy; using Microsoft.Win32; namespace WebApplication20 { public partial class _Default : System.Web.UI.Page { public string orgname; public string crmurl; public string metaurl; public bool offline; protected void Page_Load(object sender, EventArgs e) { #region CRM URLs and Organization Name //Determine Offline State from Host Name Response.Write(Request.Url.Host.ToString()); if (Request.Url.Host.ToString() == &quot;127.0.0.1&quot;) { offline = true; //Retrieve the Port and OrgName from the Registry RegistryKey regkey = Registry.CurrentUser.OpenSubKey(&quot;Software\\Microsoft\\MSCRMClient&quot;); orgname = regkey.GetValue(&quot;ClientAuthOrganizationName&quot;).ToString(); string portnumber = regkey.GetValue(&quot;CassiniPort&quot;).ToString(); //Construct the URLs string baseurl = &quot;http://localhost:&quot; + portnumber + &quot;/mscrmservices/2007/&quot;; crmurl = baseurl + &quot;crmservice.asmx&quot;; metaurl = baseurl + &quot;metadataservice.asmx&quot;; } else { offline = false; //Retrieve the URLs from the Registry RegistryKey regkey = Registry.LocalMachine.OpenSubKey(&quot;SOFTWARE\\Microsoft\\MSCRM&quot;); string ServerUrl = regkey.GetValue(&quot;ServerUrl&quot;).ToString(); crmurl = ServerUrl + &quot;/2007/crmservice.asmx&quot;; metaurl = ServerUrl + &quot;/2007/metadataservice.asmx&quot;; //Retrieve the Query String from the current URL if (Request.QueryString[&quot;orgname&quot;] == null) { orgname = string.Empty; } else { //Query String string orgquerystring = Request.QueryString[&quot;orgname&quot;].ToString(); if (string.IsNullOrEmpty(orgquerystring)) { orgname = string.Empty; } else { orgname = orgquerystring; } } if (string.IsNullOrEmpty(orgname)) { //Windows Auth URL if (Request.Url.Segments[2].TrimEnd('/').ToLower() == &quot;isv&quot;) { orgname = Request.Url.Segments[1].TrimEnd('/').ToLower(); } //IFD URL if (string.IsNullOrEmpty(orgname)) { string url = Request.Url.ToString().ToLower(); int start = url.IndexOf(&quot;://&quot;) + 3; orgname = url.Substring(start, url.IndexOf(&quot;.&quot;) - start); } } } #endregion using (new CrmImpersonator()) { CrmAuthenticationToken token; if (offline == true) { token = new CrmAuthenticationToken(); } else { // Notice that the Context parameter value is Page.Context. token = CrmAuthenticationToken.ExtractCrmAuthenticationToken(Context, orgname); } token.OrganizationName = orgname; token.AuthenticationType = 0; //Create the Service CrmService service = new CrmService(); service.Credentials = System.Net.CredentialCache.DefaultCredentials; service.CrmAuthenticationTokenValue = token; service.Url = crmurl; // This code shows how to create the metadata service. // It is not used in this sample. //MetadataService meta = new MetadataService(); //meta.CrmAuthenticationTokenValue = token; //meta.Credentials = CredentialCache.DefaultCredentials; //meta.Url = &quot;http://localhost/mscrmservices/2007/MetadataService.asmx&quot;; account account = new account(); account.name = &quot;Offline Impersonator: &quot; + DateTime.Now.TimeOfDay.ToString(); if (offline == false) // Explicitly set the owner ID for the record if not offline. account.ownerid = new Owner(&quot;systemuser&quot;, token.CallerId); service.Create(account); } Response.Write(&quot;Done&quot;); } } }</pre> <p>But it failed with the following error:</p> <p><span> </span><span style="font-family:Arial, Helvetica, Geneva, SunSans-Regular, sans-serif"><strong><span style="font-family:Verdana">Description: </span></strong>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br/><br/><strong><span style="font-family:Verdana">Exception Details: </span></strong>System.InvalidOperationException: OpenThreadToken failed with hr = 1008<br/><br/><strong><span style="font-family:Verdana">Source Error:</span></strong> <br/><br/> <table border=0 width="100%" bgcolor="#ffffcc"> <tbody> <tr> <td><code> <pre>Line 88: #endregion Line 89: <span style="color:#ff0000">Line 90: using (new CrmImpersonator()) </span>Line 91: { Line 92: CrmAuthenticationToken token;</pre> </code></td> </tr> </tbody> </table> </span></p> <h1>Server Error in '/WebApplication20' Application. <hr size=1> </h1> <h2><em>OpenThreadToken failed with hr = 1008</em></h2> <p> </p> what is the cause for this error and how do i overcome it?Mon, 29 Jun 2009 11:30:14 Z2009-06-29T11:30:14Zhttp://social.msdn.microsoft.com/Forums/en-US/sqldatamining/thread/0cee5411-f480-4a86-b5b4-44fac66db268#0a4554f8-3a77-4094-8cfa-56fd43ec5f57http://social.msdn.microsoft.com/Forums/en-US/sqldatamining/thread/0cee5411-f480-4a86-b5b4-44fac66db268#0a4554f8-3a77-4094-8cfa-56fd43ec5f57Scott Sewell, CustomerEffectivehttp://social.msdn.microsoft.com/Profile/en-US/?user=Scott%20Sewell%2c%20CustomerEffectivecreating primary keys in microsoft dynamics crmHi - Go ahead and mark the answer to your first question as answered and repost the second question in the CRM development forum. -<hr class="sig">Scott Sewell, CustomerEffective | http:\\blog.CustomerEffective.com | Twitter:@ScottSewellMon, 29 Jun 2009 14:09:47 Z2009-06-29T14:09:47Z