Forum Discussion
JSON column formatting extract first and last name from @me
This is the best I can find to extract first and last name, hopefully all email addresses have the same convention.
https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/formatting-syntax-reference
replace(substring(@me, 0, indexOf(@me, '@')), '.', ' ')
- DoraL420Jul 17, 2023Copper ContributorThis code worked brilliantly for me, however there was a slight issue. If the logged in user's email is not already capitalised in the format Firstname.Lastname@... the code won't capitalise the first letters. Is there possibly a work around that would capitalise the letters of a name from the email format firstname.lastname@... ?
- ganeshsanapJul 17, 2023MVP
DoraL420 Currently, there is no default operator/function available in SharePoint JSON formatting to auto-capitalize first letter in the word.
SharePoint JSON formatting currently only supports toLowerCase() and toUpperCase() to convert string into all lower case and upper case. Also, these operators/functions are only supported in SharePoint Online and not in SharePoint 2019.
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.
- ganeshsanapAug 26, 2022MVP
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.