Forum Discussion
MAVOTRP
Feb 19, 2024Copper Contributor
JSON code to reverse display name from last name first name to first name last name
Hi all. I have a JSON code on a Person column where I am trying to reverse the display name from Last name, First name to First Name Last name however the column is displaying the JSON code rather than executing and returning First Name Last name. Here is my JSON code:
{
"elmType": "div",
"txtContent": "=if(indexOf([$Scheduler.title], ',') != -1, concat(substring([$Scheduler.title], indexOf([$Scheduler.title], ',')+2), ' ', substring([$Scheduler.title], 0, indexOf([$Scheduler.title], ','))), [$Scheduler.title])"
}
Can anyone assist please? Unsure if there is a syntax error however SharePoint is accepting the code so it seems correct.
MAVOTRP If you have fixed format of display names like Doe, John, use JSON like below:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "=if(indexOf([$Scheduler.title], ',') != -1, substring([$Scheduler.title], indexOf([$Scheduler.title], ',')+2,indexOf([$Scheduler.title] + '^^', '^^')) + ' ' + substring([$Scheduler.title], 0, indexOf([$Scheduler.title], ',')), [$Scheduler.title])" }
Where Scheduler is an internal name of your person or group column in SharePoint list in this format. You can get the correct internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?
Output:
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.
MAVOTRP If you have fixed format of display names like Doe, John, use JSON like below:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "=if(indexOf([$Scheduler.title], ',') != -1, substring([$Scheduler.title], indexOf([$Scheduler.title], ',')+2,indexOf([$Scheduler.title] + '^^', '^^')) + ' ' + substring([$Scheduler.title], 0, indexOf([$Scheduler.title], ',')), [$Scheduler.title])" }
Where Scheduler is an internal name of your person or group column in SharePoint list in this format. You can get the correct internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?
Output:
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.
- MAVOTRPCopper ContributorThis worked perfectly thanks so much!