Forum Discussion

Teeroy_Lyon's avatar
Teeroy_Lyon
Copper Contributor
May 21, 2021
Solved

JSON format question

HI all,    Just wondering if anyone knows how/if this can be done.  I'm trying to format a text column in SharePoint using JSON.   I am trying to format the column to be a formatted ID in the follo...
  • ganeshsanap's avatar
    May 21, 2021

    Teeroy_Lyon Yes, you can do this using JSON formatting like below:

     

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "='REQ' + if([$ID] < 10, '00000', if([$ID] < 100, '0000', if([$ID] < 1000, '000', if([$ID] < 10000, '00',if([$ID] < 100000, '0', ''))))) + [$ID]"
    }

     

    Output:

    Note: You need to adjust the leading zeros using nested if conditions based on your requirements.


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Resources