SOLVED

Problem formatting list with JSON

Occasional Contributor

The following code in my JSON formatting file causes the list to disappear,

 

"txtContent": "=if([$Medium] == 'In-Person', 'Reason for requesting in-person: ' + [$in_x002d_personjustification], '')"

 

If I remove [$in_x002d_personjustification], or replace it with text, i.e., '[in_x002d_personjustification]' the list works with the correct formatting.

 

I have tried removing all records and creating a new one with a value in [$in_x002d_personjustification] (column name, "in-person justification"), the list still does not appear. I have seen this happen when the column name doesn't exist in the Sharepoint list, but that doesn't seem to be the problem here, unless I'm missing something.

6 Replies
UPDATE: I just tried creating a different column (this one I named reason), putting some text in it, then changing the JSON, the preview worked, but when I saved it, I got the same problem.

@hrt13 try [$in_x002d_personjustification.Value]

@BB-SPDevjust tried it, same problem. Thanks though. I realized I should have mentioned the column holds multi-line text items.

best response confirmed by hrt13 (Occasional Contributor)
Solution

@hrt13I just figured it out. I had to "Edit the current view" and check the "Display" box next to the column. :facepalm: Hopefully, I'll remember that next time.

You need to access the data from another column using it's internal name like: 

[$InternalNameOfColumn]

 

Also, make sure that you have added all the columns you are using in JSON formatting in your list view. (From list view settings).

 

Use column formatting to customize SharePoint 

@ganeshsanapthanks for the response. I was using the internal name for the column, but I forgot to "display" the column., (as I said in my last post). Thanks for responding though.