Skip to main content
Nintex Community Menu Bar

Two Infopath Forms in one Process

  • March 4, 2008
  • 8 replies
  • 9 views

Forum|alt.badge.img+8

Hi,


I want to use to Infopath forms in one process. I think this should be possible. The problem is that I want to display fields and values form Infopath form1 in the Infopath form2. Is this possible in the process by using events?


Jochen

8 replies

Forum|alt.badge.img+5
  • March 4, 2008

Can you describe more of the actual process you are trying to accomplish. 


Forum|alt.badge.img+9
  • March 6, 2008
Yes, it is absolutely possible.  I will give you a vague answer here, if you need more specifics I can provide them though there are a couple of other topics out here around this.  When you integrate InfoPath forms in your process, it automatically creates XML fields that represent each form.  In server code, you can access these XML fields and set values any way you see fit.  So after the user fills out form 1, you can have a server code event set fields in form 2 equal to their corrisponding values in form 1.  Hope this puts you on the right track.

Forum|alt.badge.img+8
  • Author
  • March 17, 2008

I have written server events events to get some data from the xml fields. but I don't know how to set the xml fields of the second infopath form.


Here is a little Code exemple I have done yet:


XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(K2.ProcessInstance.XmlFields["test"].Value.ToString());


XmlNamespaceManager nsMgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsMgr.AddNamespace("my", xmlDoc.DocumentElement.GetNamespaceOfPrefix("my"));
string approver2 = xmlDoc.SelectSingleNode("//my:myFields/my:approver2", nsMgr).InnerText;


Forum|alt.badge.img+8
  • Author
  • March 17, 2008

Probably with this statement I will be able to set a XML value


xmlDoc.SelectSingleNode("//my:myFields/my:approver2", nsMgr).Value = "text"


or is this too simple?


Forum|alt.badge.img+9
  • March 18, 2008

Little bit too simple, but almost there.  You need to put the updated xml back into your xml field, like this:


 K2. ProcessInstance.XmlFields["test"].value = xmlDoc.InnerXml


Forum|alt.badge.img+8
  • Author
  • March 18, 2008

xmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(K2.ProcessInstance.XmlFields["test"].Value.ToString());
XmlNamespaceManager nsMgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsMgr.AddNamespace("my", xmlDoc.DocumentElement.GetNamespaceOfPrefix("my"));


 xmlDoc.SelectSingleNode("//my:myFields/my:text2", nsMgr).Value = "text";
 K2.ProcessInstance.XmlFields["test"].Value = xmlDoc.InnerXml;


When I write this code I get the following error message


"Cannot set a value on node type 'Element'."


 any idea?
thx


Forum|alt.badge.img+8
  • March 18, 2008

Yes! You have to make a little change:


xmlDoc.SelectSingleNode("//my:myFields/my:text2", nsMgr).Value = "text";


should be


xmlDoc.SelectSingleNode("//my:myFields/my:text2", nsMgr).InnerText = "text";


Forum|alt.badge.img+8
  • Author
  • March 18, 2008

yes. your are rigth.


Thank you!