Extracting/Submitting DisplayName form people picker - InfoPath Dev
in

InfoPath Dev

Extracting/Submitting DisplayName form people picker

Last post 03-05-2014 07:04 AM by Jimmy. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 03-04-2014 10:30 AM

    Extracting/Submitting DisplayName form people picker

    I am trying to grab DisplayName from the people picker. I have this string: user = xNavigator.SelectSingleNode("/my:myFields/my:group/my:pc:Person/my:DisplayName", NamespaceManager).Value; When I go to submit the form I get this error: '/my:myFields/my:group/my:pc:Person/my:DisplayName' has an invalid token. Can't figure out what the deal is. Any help would be appreciated.
  • 03-05-2014 12:48 AM In reply to

    Re: Extracting/Submitting DisplayName form people picker

     Why not add a hidden text field which just display the Display Name field of the people picker control?

  • 03-05-2014 01:31 AM In reply to

    Re: Extracting/Submitting DisplayName form people picker

    There shouldn't be a my: here:

     my:pc:Person

    But is there a reason you're using code to do this? It seems like something you could do with regular rules.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-05-2014 06:16 AM In reply to

    Re: Extracting/Submitting DisplayName form people picker

    Thanks for the replies. I tried taking the My" part out. I now have an error that says "NullReferenceException was unhanded by user code. Use the "new" keyword to create an object instance. But to your question, I am trying to submit this data to SQL Server. This is the only way I know how to accomplish that. Can you possible explain to me what you mean by using simple rules to do this?
  • 03-05-2014 06:18 AM In reply to

    Re: Extracting/Submitting DisplayName form people picker

    I also like the idea of using a hidden field. I can definitely do that.
  • 03-05-2014 06:24 AM In reply to

    Re: Extracting/Submitting DisplayName form people picker

    Actually I am having trouble creating an action rule for the people picker. Not sure if you can do that.
  • 03-05-2014 07:04 AM In reply to

    Re: Extracting/Submitting DisplayName form people picker

    So you're using code to submit to the DB server? In that case you may need code, though the recommended practice is to use a web service (such as DBXL) as an intermediary for submitting to a database. That would save you from having to keep code in the form itself.

    It looks like there's at least one more mistake in your XPath. You need to change my:DisplayName to pc:DisplayName, but even if the XPath is correct, the people picker could be empty, so you should be checking for nulls.

    As you've surmised, there isn't a way to put action rules on people pickers, but a way around this is to create a hidden field whose default value formula references one of the fields in the people picker. Then you can put action rules on that hidden field and they will execute when the value of the people picker changes.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.