UserId & InitiatingUserId properties in Plugin of CRM
In CRM plugin, “IExecutionContext” contains 2 properties
- UserId
- Gets the GUID of the user for whom the plug-in invokes “on behalf of”.
- InitiatingUserId
- Gets the GUID of the user under which the current pipeline is executing.
Consider a scenario
- You have a user “RAJ” with “Sales Person” role with only “User Level” “Read” privilege on ‘Contact’
- You have a plugin on Post Deletion of ‘Contact’ with name “PostContactDelete”
- Assume in one particular scenario user “RAJ” should be able to delete a ‘Contact’
- So you can run the “PostContactDelete” plugin in the user with “SystemAdministrator” role
- (i.e., Set “Run in User’s Context” to User with admin role; In sample screen shot below I chosen my admin user whose name is ‘CRM WaSu1)
- When User “RAJ” logs in and try to delete ‘Contact’ the plug-in “PostContactDelete” fires. When you debug
- IExecutionContext.UserId = GUID of SystemAdministrator (i.e., OnBehalfOf User ‘RAJ’)
- IExecutionContext. InitiatingUserId =GUID of RAJ (i.e., Actual User)
🙂
Categories: CRM 2011, Plug-Ins
CRM, impersonation, InitiatingUserId, onbehalfof, plugin, User Id
I tried impersonation with network credentails but it’s not working. the crm is IFD crm.
Can you please help me….
Can you please fix the image titled “Plugin Run in User’s Context” it cannot be displayed.
Its fixed. Thanks for pointing out.