In my previous blog about Commenting in SharePoint Online and Microsoft lists, I explained where you can find the comments options, what are the permission considerations, working with commenting using SharePoint REST APIs, etc. In this blog I will explain how to use SharePoint Online/Microsoft List Comments in JSON formatting.
Currently it is not possible to get the actual list item comments using JSON formatting. But, you can get the count of comments added to list item using [$_CommentCount].
Follow below steps to show Comments Count in list view:
1. Go to SharePoint Online/Microsoft list, click on Add column and select Single line of text.
Add a column in list
2. Complete Create a column fly out on the right by entering a Name for column and Description if required. Once complete click on Save.
Create a column in list
3. Click on the Comments Count column, select Column settings and then select Format this column.
Format the comments count column
4. Select Advanced mode at the bottom of the Format Comments Count column fly out, delete everything from the textbox, add the following JSON and click Save.
Where [$_CommentCount] is an internal name of hidden Comment Count column SharePoint list.
Format the comments count column – Advanced mode
5. Close the Format Comments Count column fly out and you will see below output in list view:
Comments Count using JSON Formatting
Next Step: This example is just to show the comments count in list view. So, you would want to hide this column from list form. Check this documentation to hide Comments Count column from list form.
The JSON formatting sample given in this blog post demonstrates displaying flags of the counties selected in the multiple selection SharePoint choice column.
SharePoint Online JSON formatting is a powerful tool that allows users to customize the display of list data, bringing a new level of functionality and aesthetics to SharePoint online lists. In this blog post, we’ll explore an exciting and educational application of JSON formatting for displaying country flags within SharePoint lists.
The JSON formatting sample given in this blog post demonstrates displaying flags of the counties selected in the single selection SharePoint choice column.
SharePoint Online is a powerful collaboration and content management platform that empowers organizations to create, manage, and share information seamlessly. JSON formatting in SharePoint online allows users to customize the look and feel of the columns, views and forms in their SharePoint lists and libraries.
Earlier this year Microsoft updated the SharePoint JSON formatting feature and blocked most of the external domain image sources by default in custom JSON column and view formatting.
Only images from the following domains are allowed by default:
tenant domain, configured multi-geo domains and vanity domains (company.sharepoint.com)
The Solution – Modifying HTML Field Security Settings:
To address the challenge of displaying external web site domain images in JSON formatting, one effective solution is to adjust the HTML field security settings of your SharePoint site. This involves whitelisting trusted external domains or CDNs to allow their images to be displayed within your SharePoint environment. Follow these steps to implement the solution:
1. Go to your SharePoint online site.
2. Click on Settings (gear) icon from top right corner and select Site information.
3. Click on View all site settings link from Site information panel, it will open the SharePoint site settings page.
4. Under the Site Collection Administration section, locate and click on the HTML Field Security settings link.
5. Select Allow contributors to insert iframes only from the following domains, add external web site domain from where you are using the images under Allow iframes from this domain text box and click Add button.
6. Click OK button at the bottom of HTML Field Security settings page to save the changes.
Allow external site domain from SharePoint HTML Field Security settings
7. Navigate back to the SharePoint list where you are using external image with JSON formatting and refresh the web page. Now, you should see that the external images are working using the SharePoint Online JSON formatting.
Output
Before adding external site domain to SharePoint HTML Field Security Settings:
External Image URLs are not working in SharePoint Online JSON formatting
After adding external site domain to SharePoint HTML Field Security Settings:
Working External Image URLs in SharePoint Online JSON formatting
SharePoint JSON formatting is a great way to customize how columns/fields are displayed in SharePoint list/library views. Many times you want to customize SharePoint list columns (like Status or Expiry of list item) based on other date & time columns in your list. While doing so, when you try to check if date & time column is blank/empty using below expression, it won’t work as expected:
You can add one image per SharePoint list item using SharePoint image column and the images are stored in Site Assets library by default. Using SharePoint online out of the box capabilities, there is no way to download the images from SharePoint list image column. In this blog, I will demonstrate how to create add a button within a SharePoint Online/Microsoft Lists modern experience view which downloads the image from SharePoint image column.
You can use below JSON to add a button in SharePoint online list column to download the image from image column in same list. This JSON formatting can be applied to any existing column in your SharePoint online list OR if you want to create a new column and then apply JSON formatting, follow the steps given in this blog: Working with SharePoint Online/Microsoft List Comments using JSON Formatting
Where [$Image] is the internal name of your SharePoint image column. Also, make sure to edit the above JSON and replace the **YOUR-LIST-NAME** placeholder with your list’s name, as it appears in the list URL (including special characters).
This SharePoint JSON formatting code adds a button within a SharePoint Online/Microsoft Lists modern experience view which downloads the image from SharePoint image column:
Download Image from SharePoint Image column using JSON formatting