Recently we had below requirement where people picker control in a InfoPath Form allows multiple values separated by semi colon and the client wanted to format it differently so that they can use the selected entries (comma separated) in the picker control to send emails.
For example when the values are selected in People Picker control it will be in the format (Display Name) of - user1;user2;user3
And the requirement was that it should be in the format of email@example.com,firstname.lastname@example.org,email@example.com
The challenge here was of the AccountId which was in claims . Something like-
How did we achieve -
To make it simpler we broke the requirement into below parts:
- Remove the claims information and just retain the username mail address
- If multiple users are added thenn change the semi-colon to a comma separated values
- And the above 1 and 2 should loop for all the selected users in the picker control
For 1 - We used the simple formula of -> substring-after(*[local-name() = "AccountId"], "i:0#.f|membership|")
For 2 - We included eval like -> eval(Person, 'concat(substring-after(*[local-name() = "AccountId"], "i:0#.f|membership|"), ",")')
For 3 - We finally double eval like -> eval(eval(Person, 'concat(substring-after(*[local-name() = "AccountId"], "i:0#.f|membership|"), ",")'), "..")
Some of the learnings- Function Local-name() comes handy when we receive errors like "xyz .... does not point to a valid location path of a field or group"
Or we can type manually pc:AccountId instead of inserting as a field to avoid the error