【问题标题】:Obtaining logical name of the entity获取实体的逻辑名称
【发布时间】:2014-09-14 08:46:11
【问题描述】:

我正在使用后期绑定,并且在创建帐户后,我也在创建电话。我还发现一个非常 useful example 几乎做到了这一点。唯一困扰我的是以下几行:

if (context.OutputParameters.Contains("id"))
{
  Guid id = new Guid(context.OutputParameters["id"].ToString());
  String type = "account";
  followup["regardingobjectid"] = new EntityReference(type, id);
}

假设打电话的原因是一个帐户。嗯,是的,但将来可能不是。我尝试获取类型如下:

if (context.OutputParameters.Contains("id"))
{
  Guid id = new Guid(context.OutputParameters["id"].ToString());
  String type = context.OutputParameters["logicalname"] as String;
  followup["regardingobjectid"] = new EntityReference(type, id);
}

但后来我收到错误消息,告诉我这样的字段不存在。字段名称是否错误?还是我使用了所有错误的方法来检索实体的逻辑名称(即实体类型的实际名称,是该帐户、联系人还是疯狂的驴子)?

另外,我不完全确定 OutputParameters 是否适合查看。建议?

【问题讨论】:

  • 这个插件是怎么注册的? OutputParameters 将非常基于消息和模式。
  • @Nicknow 它在 CreateUpdate 上注册,事后,同步。是否开放解释?

标签: c# plugins dynamics-crm-2013


【解决方案1】:

这在context.PrimaryEntityName中可用

编辑

这是检查这是否是帐户的示例中的位

// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];

// Verify that the target entity represents an account.
// If not, this plug-in was not registered correctly.
if (entity.LogicalName != "account")
    return; 

我猜这就是他们对帐户进行硬编码的原因(丑陋!)

【讨论】:

  • 对吗?我也是这么想的。但是请查看指向 MS 的链接。他们清楚地提出了一种不同的方法。我的东西主要来自 InputParameters,但它们与 OutputParameters 一起使用。无法确定这只是 MS 的恶作剧,还是在 CRM 2013 中做事的一种新的更好的方法......
  • 你能粘贴链接吗?
  • OutputParameters 不是 2013 年的新成员 (msdn.microsoft.com/en-us/library/…) - 我相信这个答案是正确的,因为插件是在创建或更新时注册的。
  • @Nicknow 哦,很抱歉不清楚。我知道 OutputParameters 以前就在那里。我只是从来没有使用过它们。我总是选择 TargetInputParameters 中的内容。一两次,我浏览了输入和输出之间的差异,但我得到的信息(当然是正确的定义)并没有让我变得更聪明。我也回复了你的其他评论。 :)
  • @MarioZG 您指的是示例链接吗?再次检查问题,第二行,前两个词(它说“有用的例子”)。也许我应该明确地写“链接”。对不起。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-16
  • 1970-01-01
相关资源
最近更新 更多