Dynamics crm 2011 为什么IOrganizationService.Update()返回;Microsoft Dynamics CRM中不存在指定的记录类型;?

Dynamics crm 2011 为什么IOrganizationService.Update()返回;Microsoft Dynamics CRM中不存在指定的记录类型;?,dynamics-crm-2011,Dynamics Crm 2011,调用以更新早期绑定的自定义实体(已检索的记录)中的记录,将返回上述消息。代码片段如下(大量插入指令,但我将保留所有内容,因为我是CRM代码新手,可能会删除一些相关内容) 您需要更改以下两行: contactFact.sbtls\u ContactId=ContactId==Guid.Empty?空:新的EntityReference(“Contact”,contactId) contactFact.sbtls_AccountId=AccountId==Guid.Empty?空:新的Entity

调用以更新早期绑定的自定义实体(已检索的记录)中的记录,将返回上述消息。代码片段如下(大量插入指令,但我将保留所有内容,因为我是CRM代码新手,可能会删除一些相关内容)


您需要更改以下两行:


contactFact.sbtls\u ContactId=ContactId==Guid.Empty?空:新的EntityReference(“Contact”,contactId)

contactFact.sbtls_AccountId=AccountId==Guid.Empty?空:新的EntityReference(“帐户”,accountId);

要对
EntityReference.LogicalName
值使用小写字母,请执行以下操作:


contactFact.sbtls\u ContactId=ContactId==Guid.Empty?空:新的EntityReference(“contact”,contactId)

contactFact.sbtls_AccountId=AccountId==Guid.Empty?空:新的EntityReference(“帐户”,accountId);


逻辑名称区分大小写,应该是小写。

正是如此,谢谢。现在工作很愉快。对不起,问题的质量太差了;当时我有点匆忙,但实际上我做了大量的研究和实验;它只是没有像原来那样被很好地指导。很高兴它起作用了。顺便说一句,如果您使用早期绑定的实体(即,
contactFact
),您可以通过使用
contactFact.EntityLogicalName
)获得该逻辑名称-首先防止该问题。例如,
EntityReference(“contact”,contactId)
可以重写为
EntityReference(contact.EntityLogicalName,contactId)
// retrieve and update ContactFact record -

string strcontactFactId = reader["contactFactId"] == DBNull.Value ? string.Empty : (string)reader["contactFactId"];
string strcontactId = reader["contactId"] == DBNull.Value ? string.Empty : (string)reader["contactId"];
whereAmI = "retrieved strcontactId = " + strcontactId;
string straccountId = reader["accountId"] == DBNull.Value ? string.Empty : (string)reader["accountId"];

Guid contactFactId;
Guid contactId;
Guid accountId;
Guid.TryParse(strcontactFactId, out contactFactId);
whereAmI = "try to generate contactId from " + strcontactId;
Guid.TryParse(strcontactId, out contactId);
whereAmI = "generated contactId = " + contactId.ToString();
Guid.TryParse(straccountId, out accountId);

int score = reader.GetInt32(3);

whereAmI = "try to retrieve contactFact " + contactFactId.ToString();
sbtls_contactfact contactFact = (sbtls_contactfact)service.Retrieve("sbtls_contactfact", contactFactId, columnSet);  // xx prob don't need to retrieve current values
whereAmI = "try to set sbtls_ContactId to " + contactId.ToString();
contactFact.sbtls_ContactId = contactId == Guid.Empty ? null : new EntityReference("Contact", contactId);
whereAmI = "successfully set sbtls_ContactId to " + contactId.ToString();
contactFact.sbtls_AccountId = accountId == Guid.Empty ? null : new EntityReference("Account", accountId);
contactFact.sbtls_Score = score;
contactFact.sbtls_Fact = "Updated with contactId " + strcontactId + " parsed to GUID " + contactId.ToString();
whereAmI = "about to update";
service.Update(contactFact);
whereAmI = "updated";