SPS 2010 Best Practices: Retrieving the Current User in a Workflow

SPS 2010 Best Practices: Retrieving the Current User in a Workflow

What to do when you want to determine the current user in a workflow? It’s possible that the workflow runs inside the w3wp.exe worker process, in which case the current user makes sense. But it’s also possible that a workflow runs inside the owstimer.exe process, at a later time. In these cases, the current user doesn’t make sense. Instead, use the workflow originator or initiator.

To get the e-mail address of the originator user:

workflowProperties.OriginatorUser.Email

Or

workflowProperties.OriginatorEmail

To get the display name of the originator user:

workflowProperties.Originator

Or

workflowProperties.OriginatorUser.Name

To get the login name (format [domain name]\[user name]:

workflowProperties.OriginatorUser.LoginName

These techniques can be used in workflows that are created programmatically. In a SPD (no-code) workflow, you can also retrieve the workflow initiator’s e-mail address: use the User Profile web service as a data form web part in the .aspx page of the workflow to get the e-mail address whenever the initiator started the workflow.

Thanks to http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/a5c5094c-5578-4e3c-83f2-62308f9f946f/ for the info.

Please note: Also check out the SharePoint 2010 Best Practice Overview page at http://social.technet.microsoft.com/wiki/contents/articles/8666.sharepoint-2010-best-practices-en.aspx

Leave a Comment
  • Please add 6 and 1 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Carsten Siemens edited Revision 2. Comment: typ

  • Margriet Bruggeman edited Revision 1. Comment: add

  • Ed Price - MSFT edited Original. Comment: Title casing and tags. Great article!

Page 1 of 1 (3 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Ed Price - MSFT edited Original. Comment: Title casing and tags. Great article!

  • Margriet Bruggeman edited Revision 1. Comment: add

  • Worked first time , thanks

  • Carsten Siemens edited Revision 2. Comment: typ

Page 1 of 1 (4 items)