I am saving my infopath forms in a sql database and am retrieving them by following this article by S.Y.M. Wong-A-Ton:
http://www.bizsupportonline.net/infopath2007/retrieve-infopath-form-sql-display-in-new-instance-infopath.htm.
This is working great, but some users should only be able to view the forms and not add/modify them. I am hoping there is a way to launch the form using a different template or view that is an exact copy of the one that added the form except it does not allow a submit.
This is the code that opens the form in the submitform.xsn
// Convert the XML data for the InfoPath form into a byte array
byte[] bytes = Encoding.UTF8.GetBytes(data);
// Create a temp file
string fileName = Path.GetTempFileName();
// Read the byte array of the retrieved form into the temp file
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite))
{
fs.Write(bytes, 0, bytes.Length);
fs.Flush();
fs.Close();
}
// Display the form in a new instance of InfoPath
this.Application.XmlForms.Open(fileName, XmlFormOpenMode.Default);
What do I need to replace this.Application.XmlForms.Open(fileName, XmlFormOpenMode.Default); with in order to open it in the nonsubmitform.xsn?