How to format a Group By Header text with a text based on a boolean value?

56 Views Asked by At

I am working on formatting a SharePoint Online list with some JSON and I have been stuck on replacing Text for my Group By Headers:

GroupBy Header Text

After some searching, I was able to discover the "groupProps" schema, which gave me a little bit more control.

So this is what I put together:

  "groupProps": {
"hideFooter": true,
"headerFormatter": {
  "elmType": "div",
  "style": {
    "flex-wrap": "wrap",
    "display": "flex",
    "box-sizing": "border-box",
    "padding": "4px 8px 5px 8px",
    "border-radius": "6px",
    "align-items": "center",
    "white-space": "nowrap",
    "overflow": "hidden",
    "margin": "1px 4px 4px 1px",
    "font-size": "15pt",
    "font-weight": "bold"
  },
  "attributes": {
    "class": "'sp-css-backgroundColor-themePrimary', 'sp-css-backgroundColor-themeSecondary'"
  },
  "children": [
    {
      "elmType": "div",
      "txtContent": "Assigned to Me:"
    },
    {
      "elmType": "div",
      "txtContent": "Duplicate Records"
    }
  ]
}

}

Which gives me the output of:

Wrong Header Text

I tried a few different iterations of the JSON, with differing results. None of which gave me what I wanted.

This one, for example:

  "groupProps": {
"headerFormatter": {
  "elmType": "div",
  "txtContent": "=if([$IsRecordDuplicate_x003f_] == false, [$IsRecordDuplicate_x003f_.DisplayName] == 'Assigned to Me', [$IsRecordDuplicate_x003f_.DisplayName] == 'Duplicate Records')",
  "style": {
    "font-weight": "bold",
    "font-size": "15pt"
  }
}

But this gave me the output of:

false header titles

For reference: The top record has the value of "Is Record Duplicate" of false and the bottom item has a value of true.

What I would like to happen is, If the Value for the column Is Record Duplicate returns with a value of False, then name the Group Header Text: Assigned to Me . If True, then the Group Header is Duplicate Records.

I'm not sure if I need to modify via a Child Div or if I can still keep it in the initial groupProps style and most importantly, how do I pull those values in to use in a If/Else statement.

0

There are 0 best solutions below