Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

In SP2010, there was a "Department" field where I had to extract the department of a user whose name was already verified/resolved in people picker.

The code was:

var invokeAfterEntityEditorCallback = function (func) {
        var old__EntityEditorCallback = EntityEditorCallback;
        if (typeof EntityEditorCallback != 'function') {
            EntityEditorCallback = func;
        else {
            EntityEditorCallback = function (result, ctx) {
                old__EntityEditorCallback(result, ctx);
                func(result, ctx);
    function onPeoplePickerFieldSet(result, ctx) {
        ownerAccount = $("nobr:contains('Author or Owner')").closest("tr").find("span.ms-entity-resolved").prop("title");

This worked great - I would enter an employee's name, the people picker would verify the name and the "Department" field would populate w/ the department of said employee.

However, I'm fairly new to SP13 and I'm noticing many things don't work the way they did in 2010. I've been looking for a SharePoint 2013 version of this JS code all over the place and nothing pops up.

In SP2013 I came up w/ this JSON query that contains all the properties - including Department. And in the console.log line, it DOES print out JUST the department. But this is on click - just to test. What I need is to be automatic like 2010. When it verifies the userName, it populates the department field.

var authOwn = $("div[title='Author/Owner']");
    authOwn.click(function () {
        var ownerDept2 = $("div[title='Requester'] input").val();
        var ownerDept = jQuery.parseJSON(ownerDept2);
        var ownerDept3 = ownerDept[0].EntityData.Department;
        console.log(ownerDept3); //this DOES pull the correct info out of the string

Can anyone point me in the right direction? I'm also fairly new to Javascript so it took me a while to decipher the code above. But like I said, it worked like a charm.

My question is if anyone has either a 2013 version of this code or something similar that works in 2013.

Thank you!

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.