SharePoint List "Group By" displaying [object Object]

Anonymous
2023-01-20T19:20:09.4533333+00:00

Hello!

I have a SharePoint List shared with my team, which displays tasks, each of which have a person in the "Assigned To" and "Assigned By" column. The names are searchable based on people in our organization.

I group the list by Status and then Assigned To. My issue is that when I group by Assigned To, it displays "1 Item is [object Object]

Untitled

The columns themselves are displaying correctly: with the profile pictures and the display name. Multiple selections are not permitted for these fields. It is only in the Group By field were it displays "[object Object]" instead of the field name

Here is my format view code:

{

"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",

"groupProps": {

"headerFormatter": {

"elmType": "div",

"style": {

"flex-direction": "row"

},

"children": [

{

"elmType": "div",

"attributes": {

"class": "=if(@group.fieldData == 'Complete', 'sp-css-backgroundColor-BgMintGreen',if(@group.fieldData == 'In Progress by Assignee', 'sp-css-backgroundColor-BgGold',if(@group.fieldData == 'Pending Action from Approver/Assigner', 'sp-css-backgroundColor-BgCoral','sp-field-borderAllRegular sp-field-borderAllSolid sp-css-borderColor-neutralSecondary')))"

},

"style": {

"display": "inline-flex",

"height": "25px",

"border-radius": "15px",

"padding-left": "8px",

"padding-top": "5px"

},

"children": [

{

"elmType": "span",

"attributes": {

"iconName": "=if(@group.fieldData == 'In Progress by Assignee', 'CirclePauseSolid', if(@group.fieldData == 'Complete', 'SkypeCircleCheck', 'ClipboardListQuestion',if(@group.fieldData == 'Pending Action from Approver/Assigner', 'Blocked','StatusCircleQuestionMark'))))"

},

"style": {

"padding-right": "6px",

"padding-top": "2px"

}

},

{

"elmType": "div",

"style": {

"display": "inline-flex",

"padding-right": "9px"

},

"children": [

{

"elmType": "div",

"style": {

"padding-left": "5px"

},

"attributes": {

"class": "ms-fontWeight-bold"

},

"txtContent": "=@group.count"

},

{

"elmType": "div",

"style": {

"padding-left": "5px"

},

"attributes": {

"class": "ms-fontWeight-normal"

},

"txtContent": "= if(@group.count!= 1,'Items are','Item is')"

},

{

"elmType": "div",

"txtContent": "=@group.fieldData",

"attributes": {

"title": "=@group.fieldData",

"class": "ms-fontWeight-bold"

},

"style": {

"padding-left": "5px"

}

}

]

}

]

}

]

}

}

}

Note: I have found these existing forums but the issue was slightly different and did not resolve my question:

Microsoft 365 and Office SharePoint Development
Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Xuyan Ding - MSFT 7,601 Reputation points
    2023-01-23T08:04:50.75+00:00

    Hi @Sarah Sims ,

    You need to modify one line of your code to show two levels of grouping as follows.

    "txtContent": "=if(@group.columnDisplayName == 'Modified By', 'Modified By', '@group.fieldData')"
    

    Among them, I used the 'Modified By' column instead of your 'Assigned To' column for testing, you can replace it at any time.

    User's image

    ==================Update

    Display the specific name: You need to add the following code segment and modify the content in the above "txtContent".

    {
                    "elmType": "span",
                    "txtContent": "=@group.fieldData.title",
                    "attributes": {
                      "title": "=@group.fieldData.title",
                      "class": "ms-fontWeight-semibold"
                    },
                    "style": {
                      "padding-left": "5px"
                    }
                  },
    
    "txtContent": "=if(@group.columnDisplayName == 'Modified By', '@group.filedData.title', '@group.fieldData')"
    
    

    The result is displayed as follows:

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. 


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.