I have a custom list in SharePoint 2013 and I'm using a javascript file to style it utilising the JSLink capabilities to reduce server load etc. The problem I'm having is that my custom list as a few different custom fields in it that I need to display and my question is how do I show those fields?
(function () {
var itemCtx = {};
itemCtx.Templates = {};
itemCtx.Templates.Header = "<div><h1>Test Head</h1></div><table>";
itemCtx.Templates.Item = ItemOverrideFun;
itemCtx.Templates.Footer = "</table>";
itemCtx.BaseViewID = 1;
// 100 is Custom List
itemCtx.ListTemplateType = 100;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);
})();
function ItemOverrideFun(ctx) {
var Title = ctx.CurrentItem.Title;
var Body = ctx.CurrentItem.Body;
var ID = ctx.CurrentItem.ID;
return "<p>" + Title + "</p>" +
"<p>" + Body + "</p>" +
"<p>" + ID + "</p>" +
"<a href='/Lists/Company%20Announcements/DispForm.aspx?ID=’+ _announcementID +’> Read More</a></td></tr>" ;
}
My code works however the CurrentItem.Body renders as "undefined" and I'd like it to be my field called "BodyText".
Does anyone know how I can do this?