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;



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?

1 Answer 1


Probably the simplest way the field to be accessible in rendering template, just to include this field in a List View.

Go to Edit View page and select the column as shown on figure below enter image description here

Then you could access this field:

var assignedTo = ctx.CurrentItem.AssignedTo;
  • I know how to do that but this is a custom column called "BodyText" and I want to display that. Simply typing ctx.CurrentItem.BodyText It comes back as undefined.
    – Yanayaya
    Jun 3, 2014 at 15:10
  • This occurs since your custom column is not included in a list view. Please make sure that the view where custom rendering is applied contains this field. Jun 3, 2014 at 15:28
  • Thanks for that, the columns are in the view I've made sure, what I've noticed is that the column "BodyText" is rich text if that makes difference. I made another column for the username of the person who wrote the news article and I can't display that either despite it being shown in the view. They just come back as undefined. It's so frustrating am I missing something?
    – Yanayaya
    Jun 4, 2014 at 8:07
  • Try to to comment the line: itemCtx.BaseViewID = 1; since you are customizing the current view. I hope it will do the trick Jun 10, 2014 at 8:45
  • Great, glad it works finally! ;) Jun 11, 2014 at 7:30

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.