无法将 GUID 保存到微软 CRM 实体
本文关键字:微软 CRM 实体 保存 GUID | 更新日期: 2023-09-27 17:56:19
>我将服务声明为:
protected OrganizationService Service =
new OrganizationService(
new CrmConnection(
new ConnectionStringSettings(
然后,我更新如下所示的 guid 字段:
var query = new QueryExpression("contact");
query.ColumnSet.AddColumn("contactid");
query.ColumnSet.AddColumn("parentcustomerid");
query.Criteria.AddCondition("contactid", ConditionOperator.Like, crmPerson.PersonId);
var result = Service.RetrieveMultiple(query);
if (result.Entities.Any())
{
var r = result.Entities[0];
r.Attributes["parentcustomerid"] = crmPerson.OrganizationId;
Service.Update(r);
}
执行此操作时出现以下错误(字符串字段似乎有效)
System.ServiceModel.FaultException`1 was unhandled
HResult=-2146233087
Message=System.InvalidCastException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #52B2CA82
Source=mscorlib
我该如何解决这个问题?
parentcustomerid
是一个查找字段,您需要使用EntityReference
而不是Guid
来设置值。
r.Attributes["parentcustomerid"] = new EntityReference("account", accountId);