I'm using the following code in a webpart JSLink to pull user information from a Person and Groups Field:
(function () {
var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.Item = itemOverrideFunc;
overrideCtx.BaseViewID = 1;
overrideCtx.ListTemplateType = 100;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
function itemOverrideFunc(ctx)
{
var users = ctx.CurrentItem["People"];
for(i = 0; i < users.length; i++){
var curUserName = users[i].title;
// access department information of user or group
var curUserDepartment = users[i].department;
// access email address of user or group
var curUserEmail = users[i].email;
// access job title of user or group
var curUserJobTitle = users[i].jobtitle;
// access user picture url
// contains the picture form the user profile service
var curUserPicture = users[i].picture;
}
var ret = "<div class=\"divname1\" style=\"margin-bottom:20px;clear:both;\">"
ret += "<div class=\"divname2\" style=\"float:left;width:90px\">"
ret += "<img src=\"" + curUserPicture + "\"\>" + "</div>"
ret += "<div class=\"divname3\" style=\"float:left;width:500px;\">"
ret += "<h2 style=\"margin-bottom:0px;padding-bottom:0px\">" + curUserName + "</h2><a href=\"mailto=" + curUserEmail + "\">" + curUserEmail + "</a><br/>" + curUserJobTitle + "<br/>" + curUserDepartment + "<br/>" + ctx.CurrentItem.About_x0020_Me + ""
ret += "</div><div style=\"clear:both\"></div>";
ret += "</div>";
return ret;
}
Everything is working great except the curUserJobTitle which returns an "undefined" error.
Any ideas?