Diagnosing changes with the Modern SharePoint page version history.

If you love SharePoint, then you already know about it’s rich document and information management capabilities. Version history is a feature of SharePoint that is extremely powerful if you need to look back in history at the changes of an item. This works great if you are working with list items only, as you can see how the fields have changed on a specific item overtime. For documents and pages, SharePoint version history is unable to show us exactly what has changed within those pages.

Turns out, in modern SharePoint we do have better version history which shows us what changes have been done to modern site pages! This is an extremely powerful tool to keep track of changes of your modern SharePoint site pages over time. 

Viewing Version History

In order to view the version history of your modern SharePoint site pages, navigate to the page in question. In my scenario, we’ll be looking at a Communication site home page which has a series of hero, news and events web parts on it.Homepage

Accessing the version history is easy. On the page in question, select the “Published” button next to the “Edit” button in the top right of the page. The page will re-render and load a slide out panel from the right hand side, showing the version history of the page.

HomeVersion

Notice how you can see a history of changes that were completed on the page. In my example, edits were made to News, Spacer, Text, Quicklinks, and Events between version v3.0 and v2.0. If I would like to dive into this a bit more, I can select “Highlight changes on the page” toggle from the top of the panel. When turning this one, new boxes will highlight around the web parts that were changed with a specific color.

HomeVersion2

Green means added, Yellow means edited and Red means deleted.
How awesome is that!? Do you think this is valuable? Any new features you’d love to see come to version history?

Rendering multi-value Choice fields vertically using JSON Column Formatting

Recently I was perusing a SharePoint forum post and a member asked if there was a way to change the visual representation of a multiple value choice field in SharePoint. My first thought was to use JSON Column Formatting.

The problem

By default, SharePoint renders a multiple value choice field as a single string in a row, and renders the HTML as a single value in a div.

HTMLChoiceField

One question, if you aren’t familiar with JSON Column Formatting is how would we render these items as new lines if they represented as a single value in the HTML. You’d probably first go and see if you could split on the commas “,”… but unfortunately column formatting does not support a split function.

Introducing ‘forEach’

One feature that column formatting does have is the forEach function. This is an optional property that allows an element to duplicate itself for each member of a multi-valued field. To loop through multi-value fields we’d use the following format

"iteratorName in @currentField" or "iteratorName in [$FieldName]"

Once you’ve implemented the forEach, you have access to each member you are looping through by using the iterator name. For example, if we loop through @currentField using the following formula: "iteratorName in @currentField" we can gain access to each record using [$iteratorName].

Putting it into action

Now that we know we can loop through multi-choice fields, all we need to do is come up with a JSON column formatter which creates each record on it’s own row. See the below JSON object.

We are using the forEach property to loop through each choice value in the currentField. For each record, we set the textContext equal to the choice record, and then we just style the div to be displayed block and 100%

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "debugMode": true,
  "elmType": "div",
  "children": [
    {
      "elmType": "div",
      "style": {
        "display": "block",
        "width": "100%"
      },
      "forEach": "choice in @currentField",
      "txtContent": "[$choice]"
    }
  ]
}

The end result turns the original choice field, to be rendered like so:

ChoicesHTML

MultipleLineChoice