Plugins CRM 2013-检索OOB的价值;“客户ID”;领域

Plugins CRM 2013-检索OOB的价值;“客户ID”;领域,plugins,dynamics-crm-2013,Plugins,Dynamics Crm 2013,我正在使用插件创建自定义票号,但在“客户”字段中检索所选用户时遇到问题。如何从似乎引用OOB“联系人”实体的OOB“案例”实体中获取所选值?我一直在字符串中返回“Microsoft.XRM.Sdk.EntityReference”。哈哈 var custName = myEntity.Attributes["customerid"]; <--nope var custName = myEntity["customerid"]; <--nope var custName = myEnt

我正在使用插件创建自定义票号,但在“客户”字段中检索所选用户时遇到问题。如何从似乎引用OOB“联系人”实体的OOB“案例”实体中获取所选值?我一直在字符串中返回“Microsoft.XRM.Sdk.EntityReference”。哈哈

var custName = myEntity.Attributes["customerid"]; <--nope
var custName = myEntity["customerid"]; <--nope
var custName = myEntity.GetAttributeValue<string>("customerid"); <--I had high hopes for this, but only get a blank value. :(

var custName=myEntity.Attributes[“customerid”] 
customerid
字段是一个查找字段,因此服务器端获得
EntityReference
是正常的。正确的方法是这个

EntityReference customerRef = myEntity.GetAttributeValue<EntityReference>("customerid");
string customerName = customerRef.Name;
EntityReference customerRef=myEntity.GetAttributeValue(“customerid”);
字符串customerName=customerRef.Name;

我尝试了这种方法,但只得到了一个空值。我确实进一步研究了OOB联系人实体,我认为复合字段可能是问题的一部分?默认情况下,它被称为“全名”,但当我尝试引用它时,会出现“.key not in dictionary…”错误。有什么想法吗?如果你得到一个空值,你总是可以检索联系人/帐户实体,比如实体customer=service.retrieve(customerRef.LogicalName,customerRef.Id,new ColumnSet(true));并从客户实体获取字段值。我不确定为什么我必须跳过所有这些障碍,但这确实起到了作用。谢谢你的帮助@Guido