bitcycle
bitcycle

Reputation: 7792

C# to fill out InfoPath Form programmatically?

Is it possible to fill out an infopath form and submit it via a C# console application?

If yes, then how?

Upvotes: 3

Views: 5181

Answers (3)

user1228735
user1228735

Reputation: 11

  • 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

Upvotes: 0

Henry
Henry

Reputation: 1

MrFox is right, an Infopath Form is just an Xml document that conforms to certain rules, so as long as you create the text file with the correct Xml markups, then you've created an Infopath doc. There are, however, programmatical ways to manipulate a document using the Infopath space. In particular, you can create a new Infopath document from an Infopath template. Lookup more information on XDocuments2.NewFromSolution() to see some examples.

Upvotes: 0

MrFox
MrFox

Reputation: 3253

Yes, you can create a XML file within your C# application and push it to your Sharepoint Form Library. Sharepoint won't realize any difference.

Just ensure two things:

  • Your XML must validate against the Infopath schema.
  • Remember to add the XML processing instructions, so that Sharepoint and Infopath know how to handle the XML file. (Simply 'steal' it from an Infopath generated XML.)

Upvotes: 4

Related Questions