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

3.7k views Asked by At

When i tried to create another type of an entity record in the post update plugin stage I have gotten "Changing security attributes is not allowed in stage 20 plugins" error. Its working fine in Dynamics CRM 2013 SP1 CRM. After update CRM 2013 to CRM 2015 i got this error

3

There are 3 answers

0
user1662380 On BEST ANSWER

Remove unwanted attribute from plugin images.only select attribute that you need in the plugin.You can set it when you registering plugin(don't tick all attributes check box).remove security related attribute(owner, modified by, created on)

0
user1662380 On

Remove logic from pre create and move it to post create of the other entity. then it will working fine

1
Jorge On

Some of you might get this error in the plugin steps when an organization is being migrated to CRM 2015. Cause:

  • You change the ownership of the record in the record Pre-creation

Resolution:

Sample code:

//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...");
            }
        }

Found another solution: Move your plugin step to Pre-Validation.