Subscribe via RSS Feed Connect with me on LinkedIn

User Profile Data in SharePoint Designer Workflows

[ 12 ] April 11, 2011 |

One of the great features in SharePoint Designer workflows in SharePoint 2010 is the ability to use User Profile properties in SPD generated workflows.

Most examples that are shown demonstrate finding the manager of a user and then assigning them a task or sending them an email. However since you can use can use any profile property then there is considerable flexibility in what you can do.

Imagine if you have a announcements list and you wanted to ability to send an email with the announcement to a number of users. However you want to be able to send an email to different people depending on the ‘Department’ that the user that created the announcement was a member of.

In MOSS 2007 you would probably have something like this:

image

Since you didn’t really have access to the User Profiles of a user you had no idea who the department was, hence you would have to hard wire the options.

However in SharePoint Designer 2010 we can now easily get access to the User Profile and hence create only one workflow with some logic that will send the appropriate email.

So below we have some simple logic. Essentially I have a workflow variable that will check if the User Department is equal to a value. If it matches then a email to that group of users will be sent out.

image

Now how to find out the department that the user that created the item belongs to? Well first we need to set our worfklow variable ( in this case called User Department). So select the ‘ Set Workflow Variable’ action.

image

Now choose the variable that we want to set which is the User Department variable that I created earlier. Now the really cool part comes in. Click on the value link and select the little Fx button. This will bring up the ‘Look up for String’ modal:

image

In the Data Source choose the ‘User Profiles’ list as the Data Source and the ‘Department’ field as the ‘Field from source’ value.

image

This gives us access to all of the profile properties which is great! If you have a close look you can see all of the profile properties available:

image

However our requirement is the Department of the user that created the Announcement. So from the ‘Find a List Item’ field select ‘Account Name’, it’s the only option anyway. Now we need to do a look up to the value that we require. Click on the Fx symbol again next to the Value field.

Now we want the creator of the current item so we need the following in the look up:

  • Data Source: Current Item (This is the current item that the workflow is running on)
  • Field From Source:  Created By ( This is the user that created the current item)
  • Return Field As: Login Name (This will be used to get the appropriate User Profile)

image

And that’s it! What will now happen is when the workflow runs firstly the user that created the item that the workflow is running on will be found. Then the User Profile of that user will be retrieved from which we will assign the Department field to our variable. Then we do the check and send an email to an appropriate group.

image

Now we simply have one workflow that a user can trigger that will contain the logic needed.This is some powerful capabilities that we can easily leverage for many business processes.

Let me know if you have any questions!

Tags: , ,

Category: General, How To

About Michal Pisarek: Michal Pisarek is the founder of Dynamic Owl Consulting and a Microsoft SharePoint MVP. View author profile.

Comments (12)

Trackback URL | Comments RSS Feed

  1. Dean says:

    When i try this, the login name value is not working because it is coming back as FirstName lastName instead of domainuserId. Any idea why this might be happening in my environment or how to work around this?

  2. Henry says:

    Is the user profiles data source exposed by default or are you using BCS to extract the data? I don’s see User Profiles when I follow your example.

    Thx.

  3. Jason says:

    Can this be done with SPD 2007?

    Thanks.

  4. Rob says:

    Echoing Henry, I do not see User Profiles as a datasource. Is this an option that must be configured somehow? If so, how? — Thanks so much!

  5. Mikhail says:

    To enhance workflow authoring we offer HarePoint Workflow Extensions software ( http://www.harepoint.com/Products/HarePointWorkflowExtensions/ ) – about 200 new workflow activities, including free ones. It’s fully supported by SharePoint Designer 2010 and allows to operate with user profiles through appropriate activities.

  6. DL says:

    Re: the first poster, as to why the drop down option to select formating doesn’t work. It seems to work with OOTB fields like Created By and Modified By.

    Might want to see if the option to show email, login etc only shows if the field is required. What I’m trying next.

  7. DL says:

    Actually turns out my problem was that InfoPath 2010 doesn’t promote a people picker to a User field but rather a Single Line of Text. The problem may be infopath not outputing a user field with promoted fields.

  8. Darren says:

    I have the same question as Rob and Henry. I cannot see User Profiles as a data source. Any idea why not? Thanks.

  9. 7ogait says:

    i have the same problem… in data source i don’t have user profiles..

  10. Let me find out why you guys can’t see the data source. Can I ask what version of SharePoint are you using? What permissions do you have to the MySite host?

  11. 7ogait says:

    hi, i have SharePoint Foundation and i have full access to the website..

    What permissions do you have to the MySite host?
    I have full permissions on SharePoint.. but i’m a user in the AD

  12. SC Vinod says:

    Hi,
    Nice post. I have a question. Is it possible to query the User Profiles list against some other column other than Account Name, because I have only the display name data in my list items which I do not in the options. Is there any solution for this problem? Thanks.

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.