Skip to main content
Nintex Community Menu Bar

Sharepoint 2016 on premis (not online)

 

I have a multi person allowed field in the list.  What i’m trying to do is parse out each person, by account name, to first and last name and place them into a multiline text box.  Seems like it should be easy, but i keep pulling errors.

The first thing i do is use a collection operation > add > to place each value into a collection variable.  I then for each loop through the collection and place each value into a person variable.  Then I use a query user profile with that person variable to populate two text variables (first, last).  after that I try to concatenate a multiline text variable with each instance of the first,last.  It’s crashing on the first step and i’m getting a partial error string in the log that indicates the person field is carrying a lot more than just the account.

Has anyone done this successfully?

 

Thanks!

Hi @dmpawley 

 

FYI, My environment is SP Online and Nintex for Office365.

  1. Just to clarify, you have a SP List which has a People type column set for multiple selection. Right?
  2. You want to accomplish the following - extract the Firstname, LastName values and combine the values into a Text Long (multiline) control. Below is the SP List with the ProcurementTeam column having multiple people values.
  3. What is ambiguous is whether you want to extract from a single row (like above) or you want to extract from the entire list? (it may be that but each people field has only a single name)
  4. The value of account should be something like
    i:0#.f|membership|firstname.lastname@example.com
    Is this similar to what you are getting?

Hi @Garrett ,

 

Thank you for taking the time and responding so quickly.

I think you nailed it with what I was trying to say.  To clarify number 3, I would like to extract all of the values of a single row (current record) for the multi-person field like you have exampled.  For number 4, yes it’s something like that, but also there is an element of an array where I believe I also get a record number prefixing the string per record as evidenced in the log error message “Error querying user profile. No user profile found for user '9'.”

 

Thanks again!


Hi @dmpawley 

Here is one method

  1. Set Variable of type Person or Group

     

  2. Add a “Set workflow variable”. Assign the value from your People column.
    Set the return type. (Refer to item 1 - click the ellipsis)
    My example is for Nintex 0365. Select Display Name.
  3. Display the Result using a Log to History action.
    For my result, it return as a string - User1, User2, User3
    Firstname1 LastName1, Firstname2 LastName2, Firstname3 LastName3
  4. Once you have the return string - You can use Regex to manipulate the string. Then insert the final string into your Textbox
  5. Regex => Search and Replace. Find comma “,” replace with line break or carriage return (CR).
    Figuring the - Windows CR \n\r - may proof to be hard
    I suggest to use HTML breaks - <br> and display it to a Label instead of a Textbox 
  6. Final Result - Display into a Label control
    Firstname1 Lastname1 <br>
    Firstname2 Lastname2 <br>
    Firstname3 Lastname3 <br>
    Let me know if this method can produce the result which you desire   

Method 2 - require using a Query List to capture the List Item. (Just more steps involved)

 


Hi @dmpawley 

Here is method 2

 

 

  1. Query List - Query List for the People field.
    Then Log the Output variable. Let me know what output which you get.
  2. My result is a collection - 
    / “Firstname1 LastName1”, “Firstname2 LastName2”, “Firstname3 LastName3”]]

Await your reply @dmpawley 


Hi @Garrett ,

 

I think those solutions would probably work very well for the environment you’re in, but I don’t see a lot of that in the On Premis 2016 version I have.  It feels like it shouldn’t be as hard as it is.  I did get an idea from your instructions and went to the field properties in the list and change the person field attribute from “Name with presence.”  to “Account”.  That does give me the string you had mentioned “i:0#.w|”.   It might be the container types I’m using after the collection.  In the For Each loop, should i put each collection value into a person field, a text field or?   

 

Thanks, for all your help!

 


Hi @dmpawley 

There is a Query List action in Nintex SharePoint 2016

https://help.nintex.com/en-US/nintex2016/current/sp2016/Workflow/ActionsCore/QueryList.htm

 

The Log to History

https://help.nintex.com/en-US/nintex2016/current/sp2016/Workflow/ActionsCore/LogHistoryList.htm

 

The For Loop → use a text field


@Garrett

 

I finally figured it out.

 

In the list we need two fields.  A Person or Group field configured to allow multiple selections and a Multiple lines of text field.

The workflow is slightly different than how I would have imagined it to be, but here’s the one that works.

In the first step, we query the list, as you suggested, and bound it to the current record by ID field.  We query the person field and put the results in a collection variable.

 

Then we use a regular expression to split the collection by the delimiter of a semicolon. and place it into a new collection variable that we will use.

Then we loop through the collection variable placing each instance into a single-line text variable

With the result, we query the user profile using the single-line text variable as the account and draw out the firstname & lastname fields into their own variables.

in the for each loop, we populate a multi-line text variable with the values of the first/last name vairables using a build string.  note the multi-line text variable is also the first field being populated with itself in order to build the list.  We’re using a {Common:NewLine} as a line break.

Outside of the loop, we use Update Item to put the result into the field of the list.  I found that using equals value works better than Equals workflow data.  I think it’s just a bug with the version I am using, so I stick with what works.

 

Thank you very much for all of your suggestions.  You were really helpful in helping me figure this out!


Wow @dmpawley, great job in figuring out the solution !!  

The detailed explanation - its fantastic. 
I really appreciate the updates that your issue is solved. 
Usually, I would provide similar detailed steps and explanations for NAC/NWC and O365 (environments which I have access to). I didn’t have access to a Nintex for SharePoint environment however your query is pretty straight forward. I’m glad I took up your query and was able to help you.

 

This happens to be one of the basic Nintex coding core structure 
 - Query Object (not limited to SP List)
 - Use For Each loop to process the result from the Query

The Log to History happen to be the best debugging tool during development
 - Just place it everywhere to confirm the values of variables and output  

 

Thanks for having an open mindset and a willingness to follow my guidance and suggestion.


Reply