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");

1 Answer 1


Did that in SP2016 using the SP Services library. First checked whether the field value is a group, using the GetGroupInfo operation. If it is NOT a group, you get an error (I was not interested in that scenario) - that's the drawback. If it IS a group, you get response with < Group > tag.

   operation: "GetGroupInfo",
   async: true,
   groupName: [your group's name],
   completefunc: function (xData, Status) {
      if (Status === 'success') {                                            
         $(xData.responseXML).SPFilterNode("Group").each(function () {
            groupId =  $(this).attr("ID");
      } else {
         console.log([your group's name] + ' is not a group!');

Depending on your needs, you can later use the SP Services` GetUserInfo operation as well to check whether the user is actually a Domain Group - you get response with < User > tag and IsDomainGroup property.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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