3

I am building a Form in InfoPath and I need to disable the submit button when the values of two controls of type PersonPicker I have are invalid. Each control holds just one user.

I tried to do a formatting rule that when the Field is invalid it will disable the button. But so far I haven't being able to determine if a PersonPicker has invalid data.

I don't have access to code, can this be achieved using the rules?

4
  • Can you not add validation rules :) ? sharepoint-mattharmon.blogspot.co.uk/2013/03/… Nov 4, 2013 at 15:48
  • You can no add Validation Rules to a PersonPicker apparently. At least it doesn't enable me to do so.
    – Dzyann
    Nov 4, 2013 at 15:56
  • Nope, no validation for people picker. Luckily, there is a solution using the double eval trick, but I need clarification on what you mean by "invalid". Is that if they have typed something into the people picker that doesn't evaluate as a person, or if they have chosen people who aren't in a particular group? Nov 4, 2013 at 16:07
  • @AronFoster, by invalid I mean that they have typed something into the people picker that doesn't evaluate as a person. Thanks!
    – Dzyann
    Nov 4, 2013 at 16:10

1 Answer 1

2

Using the double eval trick, you can create the following rule on your button to disable it until each people picker contains exactly 1 valid username:

not(xdMath:Eval(xdMath:Eval(dfs:dataFields/my:SharePointListItem_RW/my:PeoplePickerColumn/pc:Person, 'concat(pc:AccountType, ";")'), "..") = "User;" and xdMath:Eval(xdMath:Eval(dfs:dataFields/my:SharePointListItem_RW/my:PeoplePickerColumn2/pc:Person, 'concat(pc:AccountType, ";")'), "..") = "User;")

Now, this won't work by just copy pasting. You'll need to get both of the dfs:dataFields... pointing at the right field. You can use the function builder (perhaps in a calculated field that you'll use for testing) to get the right XPath. Paste the following into your formula builder:

not(eval(eval(Person, 'concat(pc:AccountType, ";")'), "..") = "User;" and eval(eval(Person, 'concat(pc:AccountType, ";")'), "..") = "User;")

Then switch to advanced field view and replace each "Person" with the "Person" reapeating group under each people picker group you want to use. Check the "Edit XPath (advanced)" box and copy the formula into your formatting rule. Sometimes pc:AccountType will be my:AccountType and I don't know why. You can add the AccountType field to your function builder to see which it is.

2
  • I think I didn't write my question clearly enough. I just edited. I have 2 controls PersonPicker, I want to have only one user in each of them.
    – Dzyann
    Nov 4, 2013 at 16:48
  • Ah, my mistake. Let me test and change my answer to get you a working solution. Nov 4, 2013 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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