How to pull out the first three characters of each users' last name in a list user field?

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

I have converted my list-user field to text using the UserListToNames function.  Now, I want to pull out the first three letters of each users' last name.  So when I get the results  "John Smith; Bob Jones; Robert Green" I want to convert that to "SMI, JON, GRE".  The reason I want to do this is so that I can use the shortened description on a calendar report.  The calendar report doesn't display even one full name, so I need to abbreviate to make it usable.  I've seen some examples using Left,Right to trim characters, but not sure how to account for the fact that the field may only have one name sometimes and up to three names other times. Any suggestions?

Photo of Tamara

Tamara

  • 428 Points 250 badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Try this. It tested OK



var text Names = [Your current field with the names in text format with semi colon delimiters];

var text LastNameOne = Right(Part($Names,1,";")," ");


var text LastNameTwo= Right(Part($Names,2,";")," ");


var text LastNameThree= Right(Part($Names,3,";")," ");


var text LastNameFour= Right(Part($Names,4,";")," ");


var text LastNameFive= Right(Part($Names,5,";")," ");




Upper(

List(", ",

Left($LastNameOne,3),

Left($LastNameTwo,3),

Left($LastNameThree,3),

Left($LastNameFour,3),

Left($LastNameFive,3)))
Photo of Tamara

Tamara

  • 428 Points 250 badge 2x thumb
Thank you!
YOU're QUIte WELcome
I corrected a small typo on formula variable for LastNameFive. It was pulling part 1 and not part 5.