I am stuck getting the name of the Author/editor.
I am overwriting the templates.item:
var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.Item = newView.customItem;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
In the customItem i am looping over the items and itemfields. This works oke, but not for the Author. The value for Author returns 1, instead of a name I was hoping for:
var newView = newView || {};
newView.customItem = function(ctx) {
var rows = ctx.ListData.Row;
for (var i=0;i<rows.length;i++) {
var Html = "<tr class='itemRow'><td>";
var fields = ctx.ListSchema.Field.length;
for (var i=0;i<fields;i++) {
var thisFieldLabel = ctx.ListSchema.Field[i].DisplayName;
var thisFieldName = ctx.ListSchema.Field[i].RealFieldName;
var thisFieldNameValue = checkStatusKpi(ctx.CurrentItem[thisFieldName]);
Html += "<tr class = 'fieldRow'>";
Html += "<td class = 'fieldLabel'>" + thisFieldLabel + "</td>";
Html += "<td class = 'fieldValue'>" + thisFieldNameValue + "</td>";
Html += "</tr>";
}
Html += "</td></tr>";
}
return Html;
};
I did read and try posts without any luck:
- JSLink: Userfields (Author, Editor, ...) only provide userId not username and
- Create Edit Control Block (ECB) on View with JSLink
Trying to console.log without any luck:
console.log("Created by: " + ctx.CurrentItem["Author"][0].title); // value = undefined
console.log("Created by: " + ctx.CurrentItem["Author"]); // value = 1
Can anyone help me out with this, many thnx!