4

I am trying to finish an InfoPath 2010 form that will be displayed in a form web part on my SP2010 department site. The goal of the form is to email another departments group inbox upon submission and CC anyone entered into a People Chooser control. Since this is sending from the web part, I need the full email addresses of the CC recipients as opposed to the DisplayName. So far I have:

  • 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 AccountIds from the People Picker
  • I can Pass the AccountIds to the GetUserProfileByName queryData connection

Now, the following only works if there is a single name selected in the People Chooser:

  • I can re-query the GetUserProfileByName and pass the new AccountId to the Value field
  • Lastly I can filter the Value field to only show Name="WorkEmail"

The problem I am having is when there are multiple names selected in the People Chooser. The GetUserProfileByName service doesn't seem to be able to process all of the AccountIds at the same time and it errors out.

Have any advice for a frustrated form designer?

Thanks in advance and I look forward to hearing from someone!

1 Answer 1

4

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 :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.