1

I have a multiselect person column, and need each record not just to display the users name, but also their job title in brackets, preferably deliniated by a new line.

So far, I have the following JSON:

{ "elmType": "div",
"children":[
{"elmType": "div",
"forEach": "person in @currentField",
"txtContent": "[email protected] + ' (' + @currentField.jobTitle + ')'"
} ]
}

My outputs are containing the name and title of all entries and in the wrong order, i.e.

"John Doe; Jane Doe (John Does jobTitle; Jane Does jobTitle)"

Im trying to get it to output:

"John Doe (John Does jobTitle); Jane Doe (Jane Does jobTitle)

At first it was returning nothing until i figured out that forEach doesnt work on the root. But now I cant figure out where im going wrong in the formatting....please help!

Thanks

1 Answer 1

0

When you use forEach you are setting up an iterator. In your case you've called it person so you would need to access individual values using that as the internal column name. So your format should work by adjusting it like so:

{
  "elmType": "div",
  "style": {
    "display": "flex",
    "flex-direction": "column",
    "align-items": "flex-start"
  },
  "children": [
    {
      "elmType": "div",
      "forEach": "person in @currentField",
      "txtContent": "=[$person.title] + ' (' + [$person.jobTitle] + ')'"
    }
  ]
}

I also added some style information to the root div to ensure that each of the people end up on a new line.

1
  • Thank you theChrisKent, makes total sense!
    – Bh1208.
    Commented May 12, 2022 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.