JSON formatting to show a minumum amount of words in SharePoint

Kalpana 291 Reputation points
2021-09-21T02:57:49.927+00:00

Hi

How do I apply json formatting to a large lookup column that contains many lookup items per row. The rows are growing because of the size of the lookup column.

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

1 answer

Sort by: Most helpful
  1. Allen Xu_MSFT 13,891 Reputation points
    2021-09-21T08:10:28.817+00:00

    Hi @Kalpana ,

    I used below JSON code to display lookup items in one field up to 6.

    {  
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",  
      "elmType": "div",  
      "style": {  
            "display": "block"  
      },  
      "children": [  
        {  
          "elmType":"div",  
          "forEach": "test in @currentField",  
          "txtContent": "=if(loopIndex('test') < 6, '[$test.lookupValue]', '')"  
        }  
      ]  
    }  
    

    133858-image.png

    Note that you will be not able to redirect to the lookup item by clicking on it after applying the JSON formatting, it can only show the values of lookup items.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.