I am able to get a user field and its value from a list using CSOM/JSOM. I cannot figure out how to get if the value is a user or a group.

    var context = new SP.ClientContext.get_current()
    var list = context.get_web().get_lists().getByTitle("test");
    var view = list.get_views().getByTitle("All Items");

    context.executeQueryAsync(Function.createDelegate(this, function(sender, args)
        var query = new SP.CamlQuery();
        query.set_viewXml("<View><Query>" + view.get_viewQuery() + "</Query></View>");

        var items = list.getItems(query);


        context.executeQueryAsync(Function.createDelegate(this, function(sender, args)
            var listEnumerator = items.getEnumerator();
                var listItem = listEnumerator.get_current();

                // this field is a "Person or Group" field with a group as the value
                var userField = listItem.get_item("n09_02");

                // i can get the value

                // how can i check if the value is a user or group?
        }), Function.createDelegate(this, function(){}));
    }), Function.createDelegate(this, function(){}));
}, "sp.js");

Your Answer

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

Browse other questions tagged or ask your own question.