Force InfoPath form to open with newest template version

R

rich

I have developed an InfoPath form that will probably require some
changes over time, both to the main data source as well as minor text
and image changes after its initial deployment. I would like to know
how to force forms that were created with an older version of the form
template to always open in the latest version of the .xsn that is
published on my web server. I have the On version upgrade setting set
to "Automatically upgrade existing forms" (Form Options > Advanced) but
it seems that the only way for a user to get the newest version of the
form is by filling it out as a new blank form.

Here is the process that I am currently using:

Users fill out a new form from the .xsn that I publish to a web server
on our company intranet (i.e. http://server/vdir/form.xsn) and it is
launched using Sharepoint OpenXMLDocument ActiveX scripting in an .aspx
page. When a new form is submitted, a web service that I have written
receives the entire XML from the form and creates an .xml file in a
folder within that virtual directory on the server. The web service
then sends an email with a link to open the form. The link in the email
message points to that same.aspx page which has logic to open the
specific .xml file (passed in the querystring) instead of a blank form.
I've included a bit of the code below.

Here is an example of the problem:

1. User A fills out a form using version 1.0.0.0 (solutionVersion) of
the template. All is well.

2. User B fills out a form, however the form has been republished and
is now at version 1.0.0.1. All is well.

3. The form User B filled out needs to go to User A via the email I
mentioned. But if User A has never filled out a form using version
1.0.0.1, the message they get is "This form was created with a new
version of the form template. InfoPath cannot open the new version. Do
you want to open with the older version?" User A can click yes and the
form MAY open with the template version they last used, depending on
the compatibility between forms. But even if it does open, it may not
appear the way I would want it to because it is the older version.

As I mentioned the workaround is to have the user close infopath and
then open a blank form as if they were going to fill it out. They can
then close and go back to the .xml file and it opens in the newer
version.

I don't think the code I am using really has anything to do with the
problem, but more that this may be just the way that InfoPath handles
version differences. Does anyone have any suggestions?

<%
' Are we opening an existing form or creating a new form....
Dim formFile
formFile = Request.QueryString("f")
If formFile = "" Then 'no filename specified, fill out a blank form
formFile = "nurf.xsn"
Else
formFile = "/files/" & formFile 'The forms are stored in the
'www/files' folder
End If
%>
<html>
<head>
<title>Form Loader</title>

<script language="JAVASCRIPT">
function createForm()
{
try
{
//Create an instance of the OpenXMLDocuments object.
//document.getElementById("loadmsg").innerHTML=
'Opening NURF form, please wait...';
var xmlDocObject = new
ActiveXObject("SharePoint.OpenXMLDocuments.1");
var strTemplate = "http://MY_SERVER_NAME/nurf/<%=formFile%>";
var strSaveLocation = "http://MY_SERVER_NAME/nurf/";

if (!xmlDocObject.CreateNewDocument2(window, strTemplate,
strSaveLocation)) {
document.getElementById("errormsg").innerHTML = "<b>ERROR
OCCURRED</b><br/>The call to the
SharePoint.OpenXMLDocuments::CreateDocument2 method failed!";
}
else
{
window.history.go(-1);
}
}
catch (e)
{
document.getElementById("errormsg").innerHTML = "<b>ERROR: " +
e.message + "</b><br/>Is InfoPath (and Microsoft Office 2003 with
Service Pack 1 installed?)<br/>If you have any questions please contact
the help desk";
}
}
-->
</script>
....
<!-- More HTML here to call the createForm() function and other stuff
-->
....
 
A

Adam Harding

Rich

Insert a Query View that way to access their forms they have to run a query
in your latest form, always guaranteed.

Cheers Adam
 
R

rich

Hi Adam,

Do you mean add another view to the form, or to add another data
connection that runs a query? Because my main view (actually the only
one in the form) has two data connections already, one that receives
data from an xml file and the other submits to the web service. That
part all works fine, its just that InfoPath somehow "caches" the form
template to the user's machine.

Thanks, Rich
 

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