Sujeewa Ediriweera

February 12, 2012

Accessing InfoPath form data programmatically

Filed under: SharePoint — sujeewa.ediriweera @ 4:57 am
Tags: , , ,

Overview:

In my case I have InfoPath form to capture   First Name, Last Name, and Email of customers. I need to access these values programmatically.

Understanding:

Fields declared in custom InfoPath form are stored as ‘my:{fieldname}’ format .

Field name   Display name XML representation
txtFirstName First Name my:txtFirstName
txtLastName Last Name my:txtLastName
txtEmailAddress Email Address my:txtEmailAddress

Solution:

There are many ways to access InfoPath form.  In this solution we are using following steps to retrieve InfoPath form data.

  • Identify field names and their XML representation
  • Read InfoPath form  item from InfoPath document Library
  • Load  attached InfoPath form’s XML representation  to XmlTextReader
  • Read each node using XmlTextReader and extract user input  based on our requirement

Code:

Source Code : ReadFromInfoPathForm

Out put:

About these ads

1 Comment »

  1. Alternatively you can use XPath to extract data .For the complex InfoPath forms I recommend to use XPath.

    Comment by sujeewa.ediriweera — February 16, 2012 @ 1:06 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Rubric Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: