CRM 2013 - 检索 OOB "customerid" 字段的值

CRM 2013 - Retrieve the value of the OOB "customerid" field

我正在使用插件创建自定义票号,但在 "Customer" 字段中检索所选用户时遇到问题。如何从似乎引用 OOB "Contact" 实体的 OOB "Case" 实体中获取所选值?我一直让 "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. :(

请帮忙。

customerid 字段是一个查找字段,因此服务器端得到 EntityReference 是正常的。正确的做法是这个

EntityReference customerRef = myEntity.GetAttributeValue<EntityReference>("customerid");
string customerName = customerRef.Name;