SharePoint Tip: Population Control
Sharepoint is great for organizing information and I have been really happy to see how many of us have embraced this platform. But, as with everything in life, things could be a little better ‐ a little easier. I have noticed a lot of surveys being sent out, or participation lists that need to be filled in.
Most of these lists/surveys start out in the same way:
"Please fill in:
- Your name
- Your department
- Your Business Unit
- Your email
- Your telephone"
This is pretty general information about the user ‐ and what surprised me about this process is when I thought "Wait a minute! Don't we already have all of this information in our Active Directory? Why do I still manually have to fill all of this out? Why doesn't the system just recognise me?"
Well, and here come the purpose of this post, with a little bit of column magic and a very simple workflow you can autopopulate a list based just on the current user (or a username)!
What you will need
- a sharepoint list that needs user data
- multiple columns based on the "people picker"
- Sharepoint designer to create a sharepoint workflow that triggers when a new list item is created
Ok, so you have your empty list, now we have to create 4 new columns where the "Business Unit", "Department", "email", "Telephone" data will go. Create these columns with the choice of "Person or Group".
After you choose this option, scroll down to the bottom of the list and you will see some new options available.
Now, there are a few important things to notice here: choose "no" for "allow multiple selections", and "People only" from "allow selection of". The "Choose from" option could be useful if you really want to limit the people on your list, otherwise leave it on "All Users". The "Show Field" is where all the magic happens for this whole show. This field is what determines what user information gets shown on the list.
So, if you choose the field "Department", when the user enters his name or initials the value shown will be his or her department. This is the same for all the other fields you see here (this also means that it is SUPER important that all users have up‐to‐date profiles on our Active Directory otherwise the information pulled out will be incorrect).
Choose "Business Unit", "Department", and "phone" and "E‐mail" as "show field" for the respective 4 columns as you create them.
Now you should have a list with the "Title" column (automatically generated by Sharepoint), and your 4 peoplepicker columns (plus, if I remember correctly, maybe "created" which is also automatic).
For this post I am using the example of a personal survey so the user information (name) will come from the "created by" column which is automatically generated for every new list item.
The way this auto‐population works is that the user will fill out a "New" survey/questionnaire/etc. and his user name will automatically be registed by Sharepoint and put in the "Created by" field after he or she presses "Ok". The workflow I will describe below will take the name value from the "Created by" field and copy it over to the remaining 4 (Business Unit, Department, Direct phone and E‐mail) columns. Since we already set up the 4 columns to give us this data based on the name ‐ Voila! auto‐populate!
OK, so now we move over to Sharepoint Designer 2010 to create the simple workflow which will run automatically every time a new list item is created.
Open Sharepoint designer and navigate to "File" ‐ "Open Site" and find your site/subsite that contains the list that needs this workflow (usually "team.apmoller.net/sites/[SITE NAME]..." and so on). On the left hand menu you will see a "Lists" menu and choosing that your blank list should appear on the main window.
Choose your list and after the central window changes to reflect your list properties, choose "New..." from the "Workflows" section.
A popup window will appear where you can name your workflow, type in "autopopulate" (without the quotes) and press "OK".
Now, you can start adding actions to this workflow. These actions will define what gets done, what gets affected, and when does it happen.
Now its time to define what the workflow should do. Click on "Action" and choose "Set field in current item".
When you do this you should see a "Set field to value" action. Now we have to define the fields and the values for each of the peoplepicker columns.
When you click on the "field" option you will be presented with all the available columns in your list. So we start by choosing "Business Unit". Then click on the "value" option ‐ this defines what you want to place in the "Business Unit" field.
After clicking the "Value" option it will immediately change to a blank box with a funny looking "fx" button next to it. Click on this "fx" button to define a value. A pop‐up box will appear (see image above). Keep the "Current item" value for "Data source". Choose "Created By" for "Field from source".
You have now defined that the automatic workflow starts when a new item is created and that it should copy the value of "Created by" (username) to the "Business Unit" field.
Click on "actions" and choose "Set field in current item" once more and do the same as above for "Department", "Phone" and then one last time for "E‐mail". You should now have 4 actions visible on your menu. That's it! we're done! Click on "Finish" and then close Sharepoint Designer.
Now you can go to your list and in the Settings ‐ List Settings ‐ Workflow Settings check that the new workflow is present. Test things out by creating a new item, and let me know how it goes!
(PS.‐ I know that the fields of "Business Unit", "Department", "E‐mail" and "Direct phone" are still visible when you create a new item. Making these fields invisible is a bit complex and I explain how to do this in this article).
In this demo I showed you how to autopopulate a listitem by using a simple workflow to pull the data directly from Active Directory. You can use this to save time, and ensure the correctness of the data needed by bypassing the need for user input. If you have a case where you need to input a user name instead of having the data pulled from the "created by" field, the above process can also be triggered by running the workflow from another "people & group" field. This method is applicable to both the 2007 and 2010 Sharepoint environments.