CRM Plugins – Run in User’s Context

I had a problem a couple of week ago about permissions in a workflow.  Basically we had a plugin which was set to run when one entity was saved, if certain conditions were met then we would use the details on this entity to create a new entity.  So for this example you could imagine it if we had an order entity and when we changed the status to deal done then it would create an invoice entity.

We have made a few changes to the plugin and because it was saved on disk, we found the only way to get the changes in was to unregister the plugin and then add it in again.

We then found that some of the users were getting errors when trying to  change the order to deal done.  I looked in the error logs and saw permission errors appearing.  I looked at the user role and found he didn’t have permission to create an invoice entity.

the puzzling thing was this user could create Invoice entity before but how, it seemed impossible when considering his security role
After going through the problem we finally came to the conclusion that before we had set the plugin to run in the context of an admin user but when we had registered the plugin we had chosen the option “Calling User”.
So this explains why we suddenly were getting authentication problems.  It also highlights the potential problems with installing things manually in CRM.  We probably need to automate the process and possibly screen shot the values so we could double check we were putting in the correct details.
Here are some screenshots of plugin register process


Here you can see the setting – Run in User’s Context

One thought on “CRM Plugins – Run in User’s Context

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s