I have a list that needs to contain the department of the user filling in the list item. How do I automatically fill in the department for the current user filling in the list item? Is this even possible?

Thanks in advance


I'd inject JavaScript code to the NewForm.aspx of the list. The code would execute when the new form is opened, fetch Department from User Profile Service, and fill in the field.

In order to see the fields in NewForm.aspx, create new New form using SPD, and set it as default. Then when you edit the new NewForm.aspx, you can find the Department field you want to fill in. Add ID to the HTML element (or some parent) in order to be able to reference it programmatically.

So something like below. Note that I haven't tested it, so see how data is returned from the REST query and adjust accordingly. This also requires jQuery:

$(function() {
 var siteUrl = _spPageContextInfo.siteAbsoluteUrl;

        url: siteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=SPS-Department",
        method: "GET",
        headers: { "Accept": "application/json; odata=nometadata" },
        success: function (data) {
            $("#department input field on the form you want to fill").val(data);
        error: function(error) {

you can configure a workflow for the List and trigger worflow on item creation and updation

And In workflow step use Set 'ColumnName' to UserProfile.Department

And publish the workflow that add item to list and once the workflow completes it will populate the Department of current user

  • How do I preserve the original data in the list in the workflow step Set 'ColumnName' to UserProfile.Department? – Lennart Dec 18 '17 at 10:02
  • you need to create a column with 'Department' and update/set the column with the workflow..For eq:- let say Set 'Department' to UserProfile.Department – Sunil Sahu Dec 18 '17 at 14:05

There is the 'Created By' field which give you the User Name.

  1. You could investigate using a Calculated Column to return a value, it would use a complicated 'IF' statement. You'll have to work out the correct syntax to use though. I'm not certain how well this would work, since you are trying to match up lots of user names with departments. Plus if people leave or move department the column becomes outdated.

2 Use a Lookup field to another list containing EmployeeName & Department information. Define your Lookup so it takes the Employee Name and Department field. You will need to use a separate list for the Employee List - it should contain all of your Employees and their Departments. BTW - Try to reuse a single list in all of your Sharepoint deployment to avoid data duplication). So when you select 'create new item' in your list, you then select the Employee name (look-up field), Sharepoint will automatically assign the Department too.

2.1 - upload (copy and paste) existing data. New employees can be added manually hereafter via the usual List menu '+new item'. (note: to use Quick Edit it needs to be enabled via the List Settings).

QUick Edit screen shot

copy&paste in to list using Quick Edit

  1. Otherwise custom Javascript coding might be able to do something like this, but I don't know how to help with that. Option 2 seems like the best choice to me.
  • Does this imply that in the solution no. 2, the separate list for the Employee List with all the Employees and their Departments, has to be filled manually? If not, how do I do this automatically? – Lennart Dec 18 '17 at 10:01
  • Do you have all the employee names and department info in Excel perhaps? If so, you could use Sharepoint's 'Quick Edit', to enable you to copy and paste in your employee+department data. I'll add a SP 2013 screen shot to my Answer to show you where Quick Edit is. – Tally Dec 18 '17 at 10:22

If I understood correctly, you are referring to each persons department of work. So if person X, works in department "Logistics" then you what this info to be displayed. This ca be achieved via Active Directory with a simple User Sync.


I was able to accomplish this in SP Online by:

  1. Creating the "Department" column as a Person or Group and selecting Department from the Show field dropdown.
  2. Creating a Workflow in SP Designer 2013 to Set the "Department" to "Current Item: Created By"
  3. Set workflow to run upon creation of item and publish workflow.

I also created a new form in SP Designer and edited the html to remove the field from the form so the employee didn't have the option to enter the department.

This works to populate the Department field after the form has been submitted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.