Formatting names and extracting substring

I want to collect a list of names using the format:

LastName, FirstName MiddleInitial

The comma is essential. I created a validation rule self.Contains(",") but it is compiling with errors.

Also, I would like to extract the text after the comma and use it in questions instead of using %rostertitle%. Can this be done? I assume that it will involve some variation of string.Substring(string.IndexOf(",") + 2) but I’m not sure.

Suppose there are “Jackson, Peter” and “Johnson, Peter” and you (as a respondent) are now being asked, “How old is Peter?”.

Which one?

I see your point. However, this extracted text will not be used on every occasion.

On those occasions when it is used, it may cause confusion.

Leaving this up to you to deal with this.

I have created an example that extracts the names from full names:

With some validation. Note that it is artificial. The program will assume that the entered name is the first name if no comma is specified, but will indicate that as an error:

See section “Office visitors” in the “Public example User questions and common patterns”.

Best, Sergiy

I will use with caution. Thanks for your help.