SharePoint Dragons

Nikander & Margriet on SharePoint

Determine the current user in a SPS 2010 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 adress 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.

For ongoing work regarding workflow current user retrieval best practices, see: http://social.technet.microsoft.com/wiki/contents/articles/8044.sps-2010-best-practices-retrieving-the-current-user-in-a-workflow.aspx Thanks to http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/a5c5094c-5578-4e3c-83f2-62308f9f946f/ for the info.

4 responses to “Determine the current user in a SPS 2010 workflow

  1. Pingback: Determine the current user in a SPS 2010 workflow « SharePoint … | effort.ly

  2. Pingback: SharePoint 2010 best practices towards software developers | Virtualize SharePoint and SharePoint Virtualization

  3. Pingback: Escape Business Solutions Blog

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

%d bloggers like this: