Is it possible that this is not feasible?
JSON formatting Sharepoint column
Hello,
I have a Sharepoint column with about 30 different values. These values have 11 digits.
I want to replace these 11 digit values with letters via Json formatting.
Example:
01234567890 = ABC
12345678901 = AAA
23456789012 = BBB
I manage to do this for a single value, here is the code I use:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=replace(@currentField, '01234567890', 'ABC')"
}
However, I also want to replace the other values but I can't find the good "code" (I don't know Json at all).
Could someone please help me?
Thanks in advance,
2 answers
Sort by: Most helpful
-
-
Yanli Jiang - MSFT 24,356 Reputation points Microsoft Vendor
2022-04-11T10:43:32.11+00:00 Hi @K D ,
Your needs can be accomplished.
You can use JSON code as below:{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=if(@currentField =='01234567890','ABC',if(@currentField =='12345678901','AAA','BBB'))"}
The result is shown below:
If you have 30 different values, you can stack the if statements on the basic of my code.
Thanks,
Yanli Jiang===========================================
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.