How to retrieve field values in InfoPath

by S.Y.M. Wong-A-Ton

A compilation of links to articles and video tutorials on how to programmatically set the value of a field on an InfoPath form.

In the past months/year, I’ve written several articles on how to retrieve field values in InfoPath, but the information has been buried, so I’ve decided to summarize the articles here in the hope that they’ll be easier for you to find:

  1. You can use the Value property of an XPathNavigator object to programmatically retrieve the value of a field. For a code sample on how to do this, see How do I retrieve the value of an InfoPath field through code? or Programmatically retrieve the value of an InfoPath form field using .NET code.
  2. If you want to programmatically retrieve the value of a Rich Text Box in InfoPath, you can use the method described in How to programmatically get or set the XHTML code of a Rich Text field in InfoPath 2007.
  3. If you want to programmatically retrieve all of the values of the fields in an InfoPath form all at once and store them in an object, you can use XML deserialization as described in How to deserialize an InfoPath form into a C# or Visual Basic object.

And finally, if you do not want to write code, you can use the Set a field’s value Action in a Rule to retrieve the value of a field and set it as the value of another field. For an article written by Microsoft, see Automatically set a field’s value on Office Online.

Update Jan 15, 2009:
Yesterday I published an article, which explains how to retrieve a value of a field in a repeating table from another field in the same row of that repeating table using C# code in InfoPath 2007.

Update Jul 4, 2009:
I’ve also created 2 video tutorials in which I show you how to programmatically set the value of a field in InfoPath using:

 Subscribe (RSS | Email)

Related Posts

Comments to this post were closed 30 days after it was published.

Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. Usage of techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.

Working with InfoPath