by

How To Separate Multiple Users Selected with InfoPath People Picker–No Code

If you reached this page, you’re likely looking for an answer to the dreadful issue of how to separate the selected users from the InfoPath People Picker control in a string. Well, there are a few solutions using code, but if we can come up with something that does not need to use code deployment, any web services etc. and it is good enough, then this is your answer.

First of all this is the structure we will be using in this example:

infopath-xpath-expression-people-picker

Note the pc: Person has a blue arrow? That’s the catch. The People Picker is actually a Repeating Table with a person object underneath! Keep that information for now, we will come back to it in a minute and it all will make sense. Smile

Next thing we will do is to add a regular textbox control to your form. Click “Properties” and then choose to define a formula for the default value. Also make sure the “Refresh value when formula is recalculated” is checked.

infopath-xpath-expression-people-picker-semicolumn-text-properties

In the default value dialog box, click “Edit XPath (advanced)”. Here we will use a combination of 2 powerful functions: xdMath and Eval. Essentially xdMath will recalculate the position of the xml node in the parser and the Eval an loop though collections.

Remember when we saw that People Picker control is a Repeating Table? yep, a collection. So we will use the Eval to navigate the rows of that collection, and using Concat in the create a string attach a semi column at the end of each row.

infopath-xpath-expression-people-picker-semicolumn

Don’t worry about the advanced bit, It took me a bit to get the XPath formula right. So skip thinking about it and here’s the expression all nicely done for you.

 

xdMath:Eval(xdMath:Eval(../my:ReviewTeamSection/pc:Person, 'concat(pc:DisplayName, "; ")'), "..")

 

Make sure to replace the my:ReviewTeamSection path and use yours instead. Also you can play around with the XPath expression above and replace DisplayName for AccountId or AccountType to get different values.

I hope the time I spent figuring this out can be used to save yoursSmile

 

By

No comments:

Post a Comment