Open form with a different form template

C

Chrisf

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/inf...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?
 
S

S.Y.M. Wong-A-Ton

InfoPath forms are tightly linked to the form template they were created
with, so using a different one is going to be difficult.

If you have control over the Submit button and have a way of identifying
users that are not supposed to submit the form, you could use conditional
formatting to hide the Submit button.

Another option is to use a Read-only view
(http://www.bizsupportonline.net/blog/2009/03/quick-tip-make-infopath-form-fields-read-only/)
with a rule for when the form opens (Tools > Form Options > Open and Save >
Rules) to switch to the read-only view (see this post for how to switch
views; ignore the submit part:
http://www.bizsupportonline.net/blog/2009/03/switch-read-only-view-submit-infopath/)
if the user is not supposed to modify/submit the form. You can use a
Condition on the rule for the latter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top