0

Using this as a guide I've applied some JSON formatting to the column itself, via List Settings. This has helped, yet the column is still too wide. I'd like the text to go to a new line after a ';' character.

How would I achieve this using JSON?

Here's a picture of the list with the text I'd like to format. (BTW - the column I've indicated is a look-up column).

screenshot of a list, with the field indicated that I wish to format using JSON

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "white-space": "wrap"
  },
  "txtContent": "@currentField"
}

Update 1 - in response to Ganesh's comment

It's an additional field I've brought across from a different list, it's a concatenated field, hence it had values separated by semi-colons.

pic of the columns being used on the list

1
  • Is this a multiple selection lookup column? Mar 28, 2023 at 10:49

1 Answer 1

1

Use below JSON column formatting code for your extended lookup column:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "=replaceAll(@currentField, ';', '\n')"
}

For more information, check this article: SharePoint: Replace All Occurrences of Substring in a String using JSON Formatting

Output:

enter image description here

If you want to keep ; at the end of each item in lookup column value, use this JSON:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "=replaceAll(@currentField, ';', ';\n')"
}

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.