Forum Discussion
Date field in JSON text column formatting child component shows empty.
- Sep 12, 2022In the end it turned out that adding the referenced date column to the view and converting it to the locale date string resolved the issue. If now I only could hide that entire (not only its value) date column without JSON having an issue.... But for now I can live with the solution (I've page where I show to related views of the same list next to each other, using dynamic filtering on the right one. By adjusting the column widths I can get the used date column out of site in both views. Only at the bottom the horizontal scroll bar shows up).
JPMHuls_Atos Try using this JSON:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=if([$SiteTemplate] == 'Main', 'Main ID: ', 'Main site: ') + @currentField + '\nID: ' + [$ID] + '\n' + if(Number([$MigrationDate]) != 0, 'Migration scheduled for: ' + [$MigrationDate], '')"
}
Make sure you are properly saving the JSON and not just using "Preview" option.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- ganeshsanapSep 12, 2022MVP
JPMHuls_Atos I suspected this issue (date column not being added to list view) earlier. But, in your original question you said date value was shown once while using original JSON, so I thought you already have date column added to list view.
Also, you cannot remove date column from list view now. This is a known limitation of JSON formatting >> If you want to reference any column in JSON, it should be added to list view to read it's value.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- JPMHuls_AtosSep 12, 2022Copper ContributorThank you Ganesh, the odd thing is that the ID column is not added to the view and it still shows up in de view through JSON... but then again it is a system column and for that it may be that other rules apply.