Back to column formats
Column formattingSharePoint Online

Publishing Status

Sample contains an example of using the modulo math expression for highlighting 'published', 'published with draft' and 'draft with no published versions' of pages

Publishing Status formatting preview
Sample preview · View original image

Copy. Apply. Make it yours.

Get this format

1 definition

Review the requirements below, then paste this JSON into the matching formatting panel. Show me where.

Use your list's internal column names and replace any tenant-specific URLs or flow IDs. Formatting is presentation, not a way to secure data.

Column formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "class": "=if(Number(@currentField) % 1 == 0, 'sp-field-severity--good', if(Number(@currentField) > 1, 'sp-field-severity--warning', 'sp-field-severity--severeWarning')"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "4px 8px"
      },
      "attributes": {
        "iconName": "=if(Number(@currentField) % 1 == 0, 'Accept', if(Number(@currentField) > 1, 'Warning', 'ErrorBadge'))"
      }
    },
    {
      "elmType": "span",
      "txtContent": "='v' + @currentField + ' - ' + if(Number(@currentField) % 1 == 0, 'Published', if(Number(@currentField) > 1, 'Published with Draft', 'Draft with NO published version'))"
    }
  ]
}

From the contributor

How to use this sample

Summary

Sample contains an example of using the modulo math expression for highlighting 'published', 'published with draft' and 'draft with no published versions' of pages

Before

screenshot of the sample before formatting

After

screenshot of the sample

View requirements

  • Add the version column to the view, this must be done via the "Edit current view" or classic view editing page to see the version column option.

Sample

Solution Author(s)
number-version-publish-status.json Paul Bullock & bianca-git

Version history

Version Date Comments
1.0 May 20, 2019 Initial release
1.1 June 15, 2022 Version number added
1.2 April 27, 2026 Added version number to displayed text

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.


Additional notes