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.
ExecuteOrDelayUntilScriptLoaded(function()
{
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.load(view);
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.load(items);
context.executeQueryAsync(Function.createDelegate(this, function(sender, args)
{
var listEnumerator = items.getEnumerator();
while(listEnumerator.moveNext())
{
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
alert(userField.get_lookupValue());
// how can i check if the value is a user or group?
}
}), Function.createDelegate(this, function(){}));
}), Function.createDelegate(this, function(){}));
}, "sp.js");