Wednesday, August 28, 2013

Difference between logged in user id and system user id in crm 2011

Question-
I am using  WhoAmIRequest Class to get user id but when i use the same user  id to return output as a lookup in Custom workflow and set To field  in Email entity i get error. If i compare this id with the guid of user in mscrm 2011 then i find it's different. what exactly i get from who am i request.

Answer -
The "WhoAmIRequest" returns the Id of the user that is running the current process. Automatic workflows run under the user context of the workflow owner and not under the context of the currently logged in user. This is probably why you are getting different values for the User Id.

Workflows that run on demand (a user initiates a workflow via the ribbon button) run under the context of the current logged in user. Maybe this is what you actually need.