People Picker email extraction with multiple choices - InfoPath Dev
in

InfoPath Dev

People Picker email extraction with multiple choices

Last post 04-06-2016 01:26 PM by mauleevadi. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-03-2014 04:37 PM

    People Picker email extraction with multiple choices

    Hello everyone!

    I have searched high and low for an InfoPath 2010 codeless solution to my issue to no avail. I am hoping the collective genius of the InfoPathDev forums can assist :-).

    I am building an InfoPath form that will be hosted on SP2010. The purpose of the form is to create a centralized location from which my fellow team members can send a standardized email to a group email box that is owned by another department. I want to provide a field for them to designate other people in our company that will be CC'd on the email when they submit the form. So far, this is what I've done:

    - Created a working People Picker field/control that can successfully search my SP server for multiple users
    - By using the double eval trick, I can extract all of the DisplayNames from the People Picker and insert them into a field: xdMath:Eval(xdMath:Eval(my:CC/pc:Person, 'concat(pc:DisplayName, "; ")'), "..")

    Where I am having issues is extracting the multiple emails from the DisplayNames so I can put the code into the Data Connection of the email submit. I know that it has something to do with querying the GetUserProfileByName service, and I have added that service as a data connection, but I am missing the piece that converts them to email addresses.

    Now, you may ask why I want to go through all of this trouble to convert them so badly. Well, I have discovered that when the form is filled and submitted via an InfoPath Form Web Part, it requires a full email address in the CC field to send properly. This may simply be my server, but I would rather work around this via InfoPath than deal with the fight that would ensue by bringing this issue up with my IT team.

    Anyway, thanks a million in advance for your help and I look forward to hearing from someone!
  • 03-04-2014 10:24 AM In reply to

    Re: People Picker email extraction with multiple choices

    Good morning!

    So, I have been playing around with this and made a little progress. I am now extracting the AccountId from the people picker as opposed to the DisplayName. I am then feeding that AccountId into the query of the GetUserProfileByName connection, re-querying the connection, then having it output is Value to a new field after it's been filtered to show Name="WorkEmail".

    This solution works really well if only one name is put into the people picker. I run into a problem, however, when multiple names are selected and the double eval kicks in to concat them. It seems that GetUserProfileByName doesn't understand the multiple AccoundIds.

    At this point I am really lost as to where even to begin getting over this last hump, so any help y'all can provide is greatly appreciated. Thanks again!
  • 03-10-2014 12:24 PM In reply to

    Re: People Picker email extraction with multiple choices

    Okay, for anyone else that is interested, I finally figured this out. First my schema:

    myFields
    - CC (Group)
    -- pc:Person
    --- DisplayName
    --- AccountId
    --- AccountType
    - CCConcat
    - WorkEmail

    To recap, I first added the GetUserProfileByName data connection using Clayton Cobb's awesome instructions here: http://claytoncobb.wordpress.com/tag/getuserprofilebyname/

    Next, I set the default value of CCConcat to the double eval trick the People Picker field using Peter Northcott's method here: http://tinkerersjournal.blogspot.com/2013/01/codeless-double-eval.html. This pulls the AccountIds from the people picker and separates them with a semi-colon.

    I then added the following action rules to my submit button at the bottom of the form: 

    Set a field's value: AccountName = substring-before(CCConcat, ";")
    Query using a data connection: GetUserProfileByName
    Set a field's value: WorkEmail = concat(WorkEmail, concat(Value[Name - "WorkEmail"], ";"))

    Then I set an action rule on the field WorkEmail with the condition of "CCConcat is not blank" and it reads:

    Set a field's value: CCConcat = substring-after(CCConcat, ";")
    Set a field's value: AccountName = substring-before(CCConcat, ";")
    Query using a data connection: GetUserProfileByName
    Set a field's value: WorkEmail = concat(WorkEmail, concat(Value[Name - "WorkEmail"], ";"))

    This causes the form to read the AccountIds in the CCConcat field and run them through GetUserProfileByName until the field is empty and place the results in the WorkEmail field.

    Lastly, I told the send email data connection to simply populate from the WorkEmail field and boom, the emails sends properly.

    Hope this helps someone else :-)

  • 04-06-2016 01:26 PM In reply to

    Re: People Picker email extraction with multiple choices

    I tried all the steps in the reply above and almost got it working accept that somehow it is adding submitter email at the end of WorkEmail field on submit.

     any way to get rid of that???

     Please advise.

     

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.