submit infopath form to subfolder in sharepoint form library

M

mike.wright

Searching the newsgroups and MSDN didn't help so here goes:


I have an infopath form with a field called "serverName." When I submit
the form, I would like for it to be saved in the subfolder of the form
library that matches the server name.

For example, the Form Library is
http://intranet/mysite/serverinventory/Form/AllItems.aspx.
The field serverName inside the infopath form is "server1."

When I hit submit I would like the form to be saved in
http://intranet/mysite/serverinventory/server1/server1.xml


is this possible?
 
S

S.Y.M. Wong-A-Ton

If you've published the form template to the "serverinventory" Forms Library
and have pre-created the folder "server1" under "serverinventory", then yes,
it is possible to retrieve the value of the "serverName" field through code
and use it in the OnSubmitRequest event handler to change the FolderURL and
FileName properties of the DataAdapter that submits the form, and submit the
form (see
http://msdn.microsoft.com/library/en-us/ipsdk/html/xdobjDAVAdapterObject_HV01106498.asp?frame=true).
Note: If the user enters a name in the "serverName" field and it does not
exist as a subfolder in the Forms Library, then an error will occur. So this
solution will only work for "static" values of "serverName".

If you want to dynamically create the Forms Library and/or subfolder when
submitting the form, then no, it's not possible.
 
M

mike.wright

Actually, I figured out to dynamically create the subfolder when
submitting the form :)

Below is the code in the OnSubmitRequest() that does it:

var fso = new ActiveXObject("Scripting.FileSystemObject");
var WShell = new ActiveXObject("Wscript.Shell");

// Bind objServerName to the value of the serverName field.
var objServerName = XDocument.DOM.selectSingleNode("//my:serverName");
var strServerName = objServerName.text;

//Create a new folder in the Server Inventory Document Library.
var strNewFolderPath = "\\\\intranet\\personal\\mwright\\Server
Inventory\\"
var strNewFolderFullPath = strNewFolderPath + strServerName;
var strNewFolderName = fso.CreateFolder(strNewFolderFullPath);

Then I use the "var oXmlHttp = new ActiveXObject("MSXML2.XMLHTTP");"
just MSDN shows you how to use an HTTP PUT to place the change control
form in the server name :)
 

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