Forum Discussion

MAVOTRP's avatar
MAVOTRP
Copper Contributor
Feb 19, 2024

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 th...
  • ganeshsanap's avatar
    Feb 19, 2024

    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.

Resources