【发布时间】:2016-01-06 14:33:16
【问题描述】:
是否可以在插件更新事务中删除实体?
以下代码似乎不起作用。我需要在实体更新和其他一些情况下删除实体
类似:
protected void ExecutePosAnnotationtUpdate(LocalPluginContext localContext)
{
if (localContext == null)
{
throw new ArgumentNullException("localContext");
}
if (localContext.PluginExecutionContext.Depth > 1) return;
Entity postEntityImage = null;
if (localContext.PluginExecutionContext.PostEntityImages.Contains("PostImage"))
{
if (localContext.PluginExecutionContext.PostEntityImages["PostImage"] != null)
{
postEntityImage = localContext.PluginExecutionContext.PostEntityImages["PostImage"];
}
}
Entity preEntityImage = null;
if (localContext.PluginExecutionContext.PreEntityImages.Contains("PreImage"))
{
if (localContext.PluginExecutionContext.PreEntityImages["PreImage"] != null)
{
preEntityImage = localContext.PluginExecutionContext.PreEntityImages["PreImage"];
}
}
if ((bool)postEntityImage.Attributes["isdocument"])
{
if ( some condition )
localContext.OrganizationService.Delete(postEntityImage.LogicalName, postEntityImage.Id);
}
}
`
【问题讨论】:
-
您是否尝试在异步更新阶段注册您的插件?
-
我很好奇:您是否试图阻止用户在便笺中上传文件?
-
@Alex :) 是的,几乎你是对的 .. 我想在更新事件中移动附件
-
如果您在本地,您可以打开跟踪并查看更详细的错误以确定发生了什么。
标签: dynamics-crm-2011 dynamics-crm dynamics-crm-2013 dynamics-crm-online