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:
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.
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.
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:
In the Data Source choose the ‘User Profiles’ list as the Data Source and the ‘Department’ field as the ‘Field from source’ value.
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:
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)
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.
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!