Forum Discussion
JAntill4
May 13, 2022Copper Contributor
JSON Column Formatting for a SSN/SSAN
This is the JSON Code to Format a Column to display a SSAN/SSN in the 123-12-1234 format and give a warning if they do not provide the correct length
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"style": {
"box-sizing": "border-box",
"padding": "0 2px"
},
"attributes": {
"class": ""
},
"children": [
{
"elmType": "span",
"style": {
"line-height": "16px",
"height": "14px"
},
"attributes": {
"iconName": "",
"class": ""
}
},
{
"elmType": "span",
"style": {
"overflow": "hidden",
"text-overflow": "ellipsis",
"padding": "0 3px"
},
"txtContent": "=if(indexOf(@currentField + '^', '^') == 9,''+substring(toString(@currentField),0,3)+'- '+substring(toString(@currentField),3,5)+'-'+substring(toString(@currentField),5,10),'Please enter a 10-digit SSAN!')",
"attributes": {
"class": ""
}
}
]
}
No RepliesBe the first to reply