Extract first user from a user list

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered
I have a UserList field with a unknown number of users. Is it possible to extract the first user only? Bonus: is it possible to count the number of users in list field?
Photo of Jonathan Heuer

Jonathan Heuer

  • 306 Points 250 badge 2x thumb

Posted 2 years ago

  • 0
  • 1
Photo of Dan

Dan

  • 1,176 Points 1k badge 2x thumb
Show first user from a list-user field:
ToUser(Part(ToText([User List]),1,";"))
Count users in a list-user field (this handles up to 10):
If(
not IsNull(ToUser(Part(ToText([User List]),10,";"))), 10,
not IsNull(ToUser(Part(ToText([User List]),9,";"))), 9,
not IsNull(ToUser(Part(ToText([User List]),8,";"))), 8,
not IsNull(ToUser(Part(ToText([User List]),7,";"))), 7,
not IsNull(ToUser(Part(ToText([User List]),6,";"))), 6,
not IsNull(ToUser(Part(ToText([User List]),5,";"))), 5,
not IsNull(ToUser(Part(ToText([User List]),4,";"))), 4,
not IsNull(ToUser(Part(ToText([User List]),3,";"))), 3,
not IsNull(ToUser(Part(ToText([User List]),2,";"))), 2,
not IsNull(ToUser(Part(ToText([User List]),1,";"))), 1
)
(Edited)
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
Once the record is saved the user list is alphabetized so showing the first will always be the first in the list from A-Z.
Photo of Dan

Dan

  • 1,176 Points 1k badge 2x thumb
Ahh, good point. Jonathan, can you clarify what you're trying to do here?
Photo of Jonathan Heuer

Jonathan Heuer

  • 306 Points 250 badge 2x thumb
Hmm, I never realized the post-save alphabetization! Thanks for pointing that out Matthew. I believe this will invalidate the question, as I'd assumed that the order the users were put together would be retained, but appreciate the responses, Dan.