I have defined a site column which is rendered based on another column's information. Since I am not going to show that other column I define it in like:

      <FieldRef Name="MatterRagStatus" />

The column which I am going to show in the list view is defined like:

    <FieldRef Name="MatterIndicator" />

I have defined the JSLink where I defined this field in site columns:

<Field ID="{A5AE3A8A-E42A-4A87-9D7F-09E104FED180}"
     Description="The column calculate matter status"
     Group="Evershed Site Columns">

here is my JSLink code:

(function () {
var hiddenFiledContext = {};
hiddenFiledContext.Templates = {};
hiddenFiledContext.Templates.Fields = {
    "MatterIndicator": {
        "View": IndicatorOverrideFun,
        "DisplayForm": IndicatorOverrideFun,
        "EditForm": IndicatorOverrideFun,
        "NewForm": IndicatorOverrideFun
function IndicatorOverrideFun(ctx) {
try {
    if (ctx.CurrentItem.MatterRagStatus == "1-Red")
        return "<span style='font-size: 300%; line-height: 10%;color: #FF0000;'>•</span>";
    else if (ctx.CurrentItem.MatterRagStatus == "2-Amber")
        return "<span style='font-size: 300%; line-height: 10%;color: #FFBF00;'>•</span>";
        return "<span style='font-size: 300%; line-height: 10%;color: #00FF00;'>•</span>";
} catch (e) {
    return "";

When the page was being loaded I inspected the JSLink and the context object(ctx) had value but the field in ViewData was missing. I wonder what might be the reason for that?

1 Answer 1


JSlink has one nasty side-effect.

  • Only the Fields included in the View are included in the ctx Object

In your use case I think you are mis-interpreting CSR/JSlink, there is no need to create a second MatterIndicator Field.
The whole point of CSR is that you override the display of the original MatterRagStatus Field.

If you do want separate field you either have to go get the missing data yourself with some 10 lines of Javascript I can not produce of the top of my head.

Or you can ditch JSlink and stuff this Formula in a Calculated Column (and set the datatype to Number)

="<span style=""font-size:300%;line-height:10%;"
& CHOOSE( LEFT( [MatterRagStatus] , 1) , "F00" , "FFBF00" , "0F0" )
  • You can reference all columns, even those not in the View.
  • It will work anywhere it is used in a View, that saves you from having to attach JSlinks all over the place.
  • But it does not work for Forms, you have to use CSR there.

http://www.viewmaster365.com/#/How explains all Pros and Cons

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.