Aug 25 2022 09:22 AM - edited Aug 25 2022 09:23 AM
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])",
Aug 25 2022 09:49 AM - edited Aug 25 2022 09:49 AM
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, '@')), '.', ' ')
Aug 26 2022 12:44 AM - edited Aug 26 2022 12:52 AM
@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.
Jul 16 2023 11:51 PM
Jul 17 2023 12:07 AM
@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.
Aug 25 2023 01:02 PM - edited Aug 25 2023 01:03 PM
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.