Forum Discussion
SSantos
Aug 25, 2022Copper Contributor
JSON column formatting extract first and last name from @me
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. ...
tbpdrummer
Aug 25, 2023Copper Contributor
There are some companies who's display names for the .title property do not come up as nicely as First Name 'space' Last Name. My company comes up as Last Name 'comma space' First Name.
{
"id": "122",
"title": "Tucker, Kalya",
"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"
}In order to get the first and last names from a single select person column titled 'Engineer' I had to use the 'substring' function along with the 'indexOf' function. Here's how I got each part of the person's name.
First Name:
substring([$Engineer.title], indexOf([$Engineer.title], ',')+2, indexOf([$Engineer.title] + '^', '^'))
(This works as long as the person doesn't have the ^ character in their name. And I've never met anyone with ^ in their name.)
Last Name
substring([$Engineer.title], 0, indexOf([$Engineer.title], ','))
Hope this is helpful for someone else.