Yet another flavor of using Enum functions


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 user1@contoso.com,user2@contoso.com,user3@contoso.com

The challenge here was of the AccountId which was in claims .  Something like-

i:0#.f|membership|user1@contoso.com

How did we achieve –

To make it simpler we broke the requirement into below parts:

  1. Remove the claims information and just retain the username mail address
  2. If multiple users are added thenn change the semi-colon to a comma separated values
  3. 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

Comments (0)

Skip to main content