Format column json works fine in date column in document library EXCEPT first item

%3CLINGO-SUB%20id%3D%22lingo-sub-3070337%22%20slang%3D%22en-US%22%3EFormat%20column%20json%20works%20fine%20in%20date%20column%20in%20document%20library%20EXCEPT%20first%20item%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3070337%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20community%2C%20and%20thanks%20in%20advance%20for%20your%20help.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%20a%20date%20column%20in%20a%20document%20library%20with%20this%20json%20format%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%22%24schema%22%3A%20%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fcolumn-formatting.schema.json%22%2C%0A%20%20%22elmType%22%3A%20%22div%22%2C%0A%20%20%22style%22%3A%20%7B%0A%20%20%20%20%22text-align%22%3A%20%22%3Dif(indexOf(toLowerCase('%5B%24ContentType%5D')%2C'expediente%20banco')%20!%3D%20-1%2C%20'center'%2C'')%22%0A%20%20%7D%2C%0A%20%20%22txtContent%22%3A%20%22%3Dif(indexOf(toLowerCase('%5B%24ContentType%5D')%2C'expediente%20banco')%20!%3D%20-1%2C%20'-----No%20Aplica%20en%20Expedientes-----'%2C'%3DtoLocaleDateString(%40currentField)')%22%2C%0A%20%20%22attributes%22%3A%20%7B%0A%20%20%20%20%22class%22%3A%20%22%3Dif(indexOf(toLowerCase('%5B%24ContentType%5D')%2C'expediente%20banco')%20!%3D%20-1%2C%20'ms-fontColor-grey'%2C'')%22%0A%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20works%20fine%20except%20with%20the%20first%20item%20of%20the%20document%20library%20shown%20in%20any%20view.%20For%20example%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Isidro_ISIAN_0-1643042700320.png%22%20style%3D%22width%3A%20181px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F341915iD1EFF0406934EF67%2Fimage-dimensions%2F181x118%3Fv%3Dv2%22%20width%3D%22181%22%20height%3D%22118%22%20role%3D%22button%22%20title%3D%22Isidro_ISIAN_0-1643042700320.png%22%20alt%3D%22Isidro_ISIAN_0-1643042700320.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Isidro_ISIAN_1-1643042754536.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F341916i3B713DA17E7E6AD6%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Isidro_ISIAN_1-1643042754536.png%22%20alt%3D%22Isidro_ISIAN_1-1643042754536.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3ESometimes%2C%20if%20I%20refresh%20the%20browser%20page%20this%20first%20item%20shows%20the%20correct%20date%2C%20but%20generally%2C%20it%20always%20shows%20the%20json%20formula%20rather%20thant%20te%20actual%20'%40currentField'.%20The%20issue%20only%20occurs%20with%20the%20first%20item.%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EWhy%20is%20happening%20this%20odd%20behaviour%3F%26nbsp%3B%3CBR%20%2F%3EAny%20suggestions%20to%20fix-work%20around%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi community, and thanks in advance for your help.

I have a date column in a document library with this json format:

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "text-align": "=if(indexOf(toLowerCase('[$ContentType]'),'expediente banco') != -1, 'center','')"
  },
  "txtContent": "=if(indexOf(toLowerCase('[$ContentType]'),'expediente banco') != -1, '-----No Aplica en Expedientes-----','=toLocaleDateString(@currentField)')",
  "attributes": {
    "class": "=if(indexOf(toLowerCase('[$ContentType]'),'expediente banco') != -1, 'ms-fontColor-grey','')"
  }
}

 

It works fine except with the first item of the document library shown in any view. For example:

Isidro_ISIAN_0-1643042700320.png

Isidro_ISIAN_1-1643042754536.png

Sometimes, if I refresh the browser page this first item shows the correct date, but generally, it always shows the json formula rather thant te actual '@currentField'. The issue only occurs with the first item. 


Why is happening this odd behaviour? 
Any suggestions to fix-work around?

 

Thanks!

 

0 Replies