JSON column formatting extract first and last name from @me

Occasional Contributor

Can we extract other information from @me?  For example, rather than getting the email address, I'd like to only display the First and/or Last names. I tried @me.givenname and others but didn't work. 

 

"elmType": "button",
          "customRowAction": {
            "action": "setValue",
            "actionInput": {
              "Status": "=if([$Counter] == 1, 'Approved by ' + @me, [$Status])",

 

 

2 Replies

This is the best I can find to extract first and last name, hopefully all email addresses have the same convention. 
Formatting syntax reference | Microsoft Docs

 

replace(substring(@me, 0, indexOf(@me, '@')), '.', ' ')

 

 

@SSantos "@me" will evaluate only to the email address of the current logged in user and you cannot extract display name (first/last name) from this directly like other people fields.

 

For other people fields, you can use below properties (sample data): 

 

 

{
  "id": "122",
  "title": "Kalya Tucker",
  "email": "email address removed for privacy reasons",
  "sip": "email address removed for privacy reasons",
  "picture": "https://contoso.sharepoint.com/kaylat_contoso_com_MThumb.jpg?t=63576928822",
  "department":"Human Resources",
  "jobTitle":"HR Manager"
}

 

 

where "title" returns the display name of people field.

So, to get the display name of current user, you have to use the expression like you are using.


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.