长话短说,我试图使用在预操作阶段执行的插件来获取查找值的名称。
虽然有问题的属性/字段包含实体引用对象,但由于某种原因,该对象仅包含实体引用的LogicalName和ID,但不包含名称值(为null)...
有没有人知道为什么会这样,如果有更好的解决方法而不是只是为了检索名称字段而对数据库进行服务调用?
答案 0 :(得分:0)
您可以执行以下操作来获取实体的属性:
string attribute_name = String.Empty;
Entity entity = (Entity)context.InputParameters["Target"];
EntityReference _id = (EntityReference)entity["AttributeName"];
ColumnSet col = new ColumnSet(new String[] { "name" });
var NameRetrieved = service.Retrieve("EntityName", _id.Id, col);
if (NameRetrieved != null)
{
if (NameRetrieved.Attributes.Contains("name"))
{
attribute_name = (string)productRetrieved["name"];
}
else
{
attribute_name = "";
}
}
答案 1 :(得分:0)
您可以查看Entity.FormattedValues collection是否包含您需要的属性。