CRM 2015 更新 - 插件错误 - 'Changing security attributes is not allowed in stage 20 plugins'

CRM 2015 update - plugin error - 'Changing security attributes is not allowed in stage 20 plugins'

当我尝试在 post 更新插件阶段创建另一种类型的实体记录时,我遇到了 "Changing security attributes is not allowed in stage 20 plugins" 错误。 它在 Dynamics CRM 2013 SP1 CRM 中运行良好。 将 CRM 2013 更新为 CRM 2015 后出现此错误

从预创建中删除逻辑并将其移动到另一个实体的post创建中。那么它将正常工作

从插件中删除不需要的属性 images.only select 您在 plugin.You 中需要的属性可以在您注册插件时设置它(不要勾选所有属性复选框)。删除安全相关属性(所有者、修改者、创建于)

当组织迁移到 CRM 2015 时,有些人可能会在插件步骤中遇到此错误。 原因:

  • 您在记录创建前更改记录的所有权

分辨率:

示例代码:

//Runs on the Pre-Validation step, when a Contact is created
if (context.Stage == 10)
{
    if (!targetEntity.Attributes.Contains("parentcustomerid"))
    {
        throw new InvalidPluginExecutionException("Message to show....");
    }
    try
    {
        var accountOwner = (from a in orgServiceContext.AccountSet
                        where a.Id == targetContact.ParentCustomerId.Id
                                select a).Single();
            targetEntity.Attributes["ownerid"] = new EntityReference("team", accountOwner.OwnerId.Id);
            targetEntity.Attributes["owningbusinessunit"] = new EntityReference("businessunit", accountOwner.OwningBusinessUnit.Id);
            }
            catch
            {
                throw new InvalidPluginExecutionException("Message to show...");
            }
        }

找到另一个解决方案:将您的插件步骤移至预验证。