JSON formatting to show a minumum amount of words in SharePoint

Kalpana 286 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.

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,298 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,810 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Allen Xu_MSFT 13,806 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.