SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to grab the contents of an InfoPath's FormState object? I have access to the SPListItem in the document library it resides in, the xml of the item, the document library it lives in, but I can't seem to access the key/values of the FormState.

E.g. In the code behind of my InfoPath form I have: FormState.Add("RequestName", "Changed");

I would like to grab that key value pair, but don't know if I can access it from the document library item. FormState is a XmlFormHostItem.

In the code behind of the InfoPath form, I added a few key/values pairs to the FormState object and I want to read those key values from a document library event receiver. Any suggestions?

share|improve this question

Why do you put something you want to get externally into Infopath form code-behind (basically internal) variables? FormState variables are used to maintain the values in Infopath browser forms between postbacks.

If you need to grab the values from Infopath form externally, like in Sharepoint document library, then the most simple way is to create form template's special data fields for putting/getting values both in code-behind and outside and promote those fields during publishing. Hide them if you do not want to show them in document library.

share|improve this answer
I inherited some forms that store a bunch of information in the FormState and I am trying to consolidate a bunch of that code in some document library event receivers. I was thinking of either storing that info in the xml of the form or, like you suggested, in a field and publish those fields. – Meyer Denney Aug 15 '12 at 17:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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