Back to view formats
View formattingSharePoint Online

Display User Properties in the Group Header

This sample demonstrates showing additional properties for a grouped user field in the group header. The user's picture, email, title, and department are all shown.

Display User Properties in the Group Header 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.

View formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "groupProps": {
    "headerFormatter": {
      "elmType": "div",
      "style": {
        "display": "inline-flex",
        "align-items": "flex-end",
        "height": "25px",
        "padding-left": "8px",
        "padding-top": "5px",
        "padding-bottom": "5px",
        "border-radius": "10px"
      },
      "attributes": {
        "class": "ms-bgColor-themeLighter"
      },
      "children": [
        {
          "elmType": "div",
          "txtContent": "=@group.columnDisplayName + ':'",
          "children": [
            {
              "elmType": "span"
            }
          ],
          "style": {
            "padding-right": "9px",
            "padding-bottom": "3px"
          },
          "attributes": {
            "class": "ms-fontWeight-bold"
          }
        },
        {
          "elmType": "img",
          "attributes": {
            "src": "=getUserImage(@group.fieldData.email, 'small')",
            "title": "@group.fieldData.title"
          },
          "style": {
            "width": "25px",
            "height": "25px",
            "border-radius": "50%"
          }
        },
        {
          "elmType": "div",
          "style": {
            "display": "inline-flex",
            "padding-right": "9px",
            "padding-bottom": "3px"
          },
          "children": [
            {
              "elmType": "span",
              "txtContent": "=@group.fieldData.title",
              "attributes": {
                "title": "=@group.fieldData.title",
                "class": "ms-fontWeight-semibold"
              },
              "style": {
                "padding-left": "5px"
              }
            },
            {
              "elmType": "div",
              "children": [
                {
                  "elmType": "span",
                  "attributes": {
                    "iconName": "Mail"
                  },
                  "style": {
                    "padding-left": "10px",
                    "padding-top": "3px"
                  }
                },
                {
                  "elmType": "span",
                  "txtContent": "=@group.fieldData.email",
                  "style": {
                    "padding-left": "5px"
                  },
                  "attributes": {
                    "title": "=@group.fieldData.email"
                  }
                }
              ],
              "style": {
                "display": "=if(@group.fieldData.email == '' || @group.fieldData.email == 'Unassigned' ,'none','inherit')"
              }
            },
            {
              "elmType": "div",
              "children": [
                {
                  "elmType": "span",
                  "attributes": {
                    "iconName": "Work"
                  },
                  "style": {
                    "padding-left": "10px",
                    "padding-top": "3px"
                  }
                },
                {
                  "elmType": "span",
                  "txtContent": "=@group.fieldData.jobTitle",
                  "style": {
                    "padding-left": "5px"
                  },
                  "attributes": {
                    "title": "=@group.fieldData.jobTitle"
                  }
                }
              ],
              "style": {
                "display": "=if(@group.fieldData.jobTitle == '' || @group.fieldData.jobTitle == 'Unassigned','none','inherit')"
              }
            },
            {
              "elmType": "div",
              "children": [
                {
                  "elmType": "span",
                  "attributes": {
                    "iconName": "WorkforceManagement"
                  },
                  "style": {
                    "padding-left": "10px",
                    "padding-top": "3px"
                  }
                },
                {
                  "elmType": "span",
                  "txtContent": "=@group.fieldData.department",
                  "style": {
                    "padding-left": "5px"
                  },
                  "attributes": {
                    "title": "=@group.fieldData.department"
                  }
                }
              ],
              "style": {
                "display": "=if(@group.fieldData.department == '' || @group.fieldData.department == 'Unassigned','none','inherit')"
              }
            },
            {
              "elmType": "span",
              "style": {
                "padding-left": "5px"
              },
              "attributes": {
                "class": "ms-fontWeight-bold"
              },
              "txtContent": "='(' + @group.count +')'"
            }
          ]
        }
      ]
    }
  }
}

From the contributor

How to use this sample

Summary

This sample demonstrates showing additional properties for a grouped user field in the group header. The user's picture, email, title, and department are all shown.

If any property is empty, its respective icon and label are not displayed.

screenshot of the sample

View requirements

Type Internal Name Required Details
Person or Group Any Yes Create a view, add the desired person field and group the view by this person field.

Sample

Solution Author(s)
group-header-user-properties.json Michel Mendes

Version history

Version Date Comments
1.0 November 28, 2021 Initial release

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.