Skip to main content

Hello,

I used SP 2016 on-premises, and I have SharePoint list with CAName column that has a Person and Group type and allows multiple selection which means users are able to insert more than one person in the column. CAName's data is Smith,John;Kennedy Mary. 

The goal is to display the first name first, then the last name of the people on the list (Example: Dear John Smith, Mary Kennedy) which included a comma separating them.

Is there a way to display the first name first, then the last name of multiple people from a Person or Group column which included a comma separating them? I’m appreciated for your help. 

I completed the follow steps below:

1. Create the Person or Group column (named CAName), and set Allow multiple selection to Yes.

2. Create a Nintex workflow.
3. Create a workflow variable and set the type to Single line of text. I created varDisplayNames.

4. Add Set Variable workflow action to the workflow. Set the workflow variable created in the previous step (varDisplayNames). Choose List Lookup from the Equals dropdown menu. Source is Current item. Then choose the Person or Group variable (CAName) created in the step 1 from the Field dropdown menu (in this example People List). Now click the breadcrumbs button (...) and choose Display names, Semicolon Delimited from Select return type list.

5. All the Display Names stored in the varDisplayNames variable separated by semicolon (;).

For example, the final result displayed: Smith,John;Kennedy Mary; instead of displaying the first name first, then the last name (Example: Dear John Smith, Mary Kennedy) which included a comma separating them.

I also used Query User Profile action to get the first name and last name, but it only displayed one person (Dear John Smith) instead of a multiple people's name (Example: Dear John Smith, Mary Kennedy).

Is there a way to display the first name first, then the last name of multiple people from a Person or Group column which included a comma separating them? I’m appreciated for your help. 

Hi @YV,

Follow your first 4 steps and then use a regular expression action to change the semi-colons to commas. 
 

 


Thanks, Simon. That works. I’m able to replace the semi-colons to commas. However, the final result is Smith, John, Kennedy Mary.  How can I have the first name displays first, then last name? (Example: Dear John Smith, Mary Kennedy).


Hi @YV,

Strange,  I tested this before posting, and it worked as expected.
How is the People person column configured in SharePoint?


It is the Person or Group type and allows multiple selections. The People column contains Last Name, First Name in SharePoint.

 


Hmm, This is not normal.  I would say this concerns the list or how AD is configured.
The only solution I can think of is to split the string into a collection and then loop through it to build the required string.


I used the Regular Expression to split the string into a collection and then loop through it, then used Query User Profile and store in a workflow variable to get the first name and last name (see photos below), but this will only capture the name of the last person and I cannot do that for other people in the list. 

The final result only displayed the last person (For example: John Smith) instead of displaying multiple people (Example: John Smith, Mary Kennedy). 

I’m not sure where I configured incorrectly. Did I miss anything? I appreciate your help.

 

 

Regular Expression to replace semi colons with commas.

 

Regular Expression:

 

For each loop:

 

 

Get User First Name and Last Name:

 

 

Concatenate workflow data and store in varResultCAFullName

 

Set Variable:

 

 

 

 

Full Workflow:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Hi @YV,

 

The issue is that you are overwriting the result with each loop.

You can resolve this two different ways.

The first is to change the build string action.
The text should be: FirstNameVariable LastNameVariable, varResultCAFullname.
This way you are adding to the string with each loop. You will not need the set variable action at the end of the loop.

The other way to do this is to remove set variable action at the end of the loop and use a collection operation to add the output of the build string to a collection variable instead.

When the loop completes, use the Join collection operation to create a comma-delimited string with the contents of the collection.

 


Thank you for sharing your input. I changed the build string action (See below), but it only keeps the display name of the last person (Example: Mary Kennedy) instead of displaying multiple people (Example: John Smith, Mary Kennedy). It overwrites the text variable in the loop with the last person.

I have Multiple lines of text type for varResultCAFullName variable, Collection type for varCAFullNameCollection, and Single line of text type for varCAFullName.

I'd appreciate it if you expand the option 2 by using a "collection operation to add the output of the build string to a collection variable instead. When the loop completes, use the Join collection operation to create a comma-delimited string with the contents of the collection."

 

 


Hi @YV,

That build string configuration should work.
I suggest adding a Log in the History List action before the build string and log the first and last name before adding it to the string to ensure the loop works correctly.


Thanks for your suggestion, the issue resolved after I fixed a variable. I’m able to capture a multiple people in the list, and the final result is Dear John Smith, Mary Kennedy, Kim Smith,

The extra comma displayed after the last person. How can I remove the extra comma after the last person when the loop completed? The final result should be Dear John Smith, Mary Kennedy, Kim Smith


Hi @YV,

Use a build string action with the fn-Length inline function to find out the length of the string.

Use a math operation to minus 1 from the length.
Then, use another build string and use the fn-Remove inline function to remove the last character of the string.

I have attached a simple workflow to demonstrate how to configure everything.

 

 

 


It worked as expected for when there is more than 1 person, which the final result is displayed as Dear John Smith, Mary Kennedy, Kim Smith. However, if there is only 1 person on the list, then the final result is Dear John Smith,

Is there a way to remove the comma at the end of the person’s name if there is only 1 person on the list?

The final goal is: Dear John Smith (for 1 person)

Dear John Smith, Mary Kennedy, Kim Smith (for multiple people).


Hi @YV,

The method I have provided will remove the comma regardless of how many users.
It looks at the string length and then removes the last character.
If this is not working, you may need to look at your workflow design.


Thank you, I will look into this direction. 


Reply