How can JSON column formatting be used to highlight duplicate entries in a column a list?
-
08-02-2021 - |
Question
Column formatting is used in SharePoint Online to customize how fields in lists are displayed. Microsoft provide documentation regarding the use of JSON for column formatting.
As is described in the documentation, this works well for basic things such as adding a class depending on the name of the current field. For example:
"attributes": {
"class": "=if(@currentField == 'Done', 'sp-field-severity--good', if(@currentField == 'In progress', 'sp-field-severity--low', if(@currentField == 'In review', 'sp-field-severity--warning', if(@currentField == 'Has issues', 'sp-field-severity--severeWarning', 'sp-field-severity--blocked')))) + ' ms-fontColor-neutralSecondary'"
},
The end result being:
However, is there a way to check values in the current column and apply a class or color to duplicate entries in that column?
For example, if there is a Person column entitled Participants. One list entry has the value, Smith, John
. If another entry gets created and Smith, John
is added again, both of these values would be highlighted or have a class applied.
Solution
No.
In column formatting, you cannot access/use the column values from another list item/row.
You can only access the column values from the same list item/row like [$AnotherColumnFromSameRow]
.
Where AnotherColumnFromSameRow
is internal name another column from same list item/row.