How to dynamically determine a Sharepoint Form Library to post to?

R

Rob

Hi,

I am building a Sharepoint repository for my client using Portal Server
2003. My client deals with multiple task orders and would like to have each
task order's documents in a separate Services site.

I am proposing to create Infopath forms for the various types of documents.
Since the same set of documents are used, I'm proposing to make templates
from the areas that I create and re-use them to make new task order sites.

Now here's the question: Each site will have a separate URL like:

http://sps2003/tasks/2079

If I make Infopath forms and the user opens them from the Sharepoint site,
how do I tell Infopath what area to submit the form back to? It looked as if
Infopath was expecting me to know beforehand what the area URL is. Is there
any way for me to code Infopath so that the form "knows where it came from
and how to get back there?"

Thanks for the assistance!
Rob
 
K

Kalyan Reddy

Hello Rob,

You can set the options in the submit button proprties.
Double clcik on the Submit button to open properties
Select Sharepoint Library in the Submit options window.
 
R

renee rieser

Rob,

Even though you're using the same template across a number of form
libraries, you can still publish the same form to the different
libraries. This way, no matter which task library a user goes to to
open his form, it'll know to save it in that same library because it
knows in which library it was created.

Now, if you're talking about creating one form library that users go
to to create the form, and then saving it to one in an array of
different libraries, you've got to use code to determine which library
and to perform the actual save. Even then, the form's header metadata
will still refer the form back to the originating library if they hit
the submit button, so you'll have to remember to disable that and have
them use "Save" for any edits they make after the initial creation
(otherwise, it'll be submitted back to the originating library).
 
R

Rob

That would be great, although I don't understand exactly how to do this. If I
go into the Submitting Forms option and enable the Submit to occur, then
choose Sharepoint as my "Submit to:", I have to type in a Sharepoint Form
Library URL. How does that work if I have users opening forms in say, two
URLS, one named http://sps2003/tasks/2079 and the other in
http://sps2003/tasks/2081? Inside both Sharepoint areas there would be a
Infopath library called Completion Statement of Work that came from a
template. I would want the user to be able to open the Statement of Work and
then be able to submit it back as a new version, using the same URL that the
file was checked out from.

How would I set my Sharepoint Form Library URL to make this work?

Thanks,
Rob
 
R

renee rieser

Use Tools/Data Connections/Add to run the Data Connection Wizard for
telling the form which sharepoint url it should use to submit data.

Once you're happy with the form....

Publish the form to your first library, then go into Toosl/Data
Connections. Use the "Modify" button on that connection you created to
change the library name. Publish the form to your next library.
Repeat.

If you've published the form to a bunch of libraries and now want to
make the same change(s) across all the libraries, its probably safest
to use the method above to update the form in each lib. A less safe
but sometimes more expedient method is to modify the manifest.xsf to
update the data connection.....do a search on xsf:submit to find the
right place in your manifest - it'll be close to the bottom of the
file.
 
R

Rob

So I guess the bottom line of this is that it will be difficult to do this in
an automated fashion. It sounds as if there needs to be some code that would
look in the xsf and mod the xml. I'm trying to make this more of an automated
process than having someone actually manually create the areas.
 
R

renee rieser

Ach, I take back what I said....

If you disable the submit and write custom code you can have the
master template in one folder and save the form to whichever
Sharepoint lib is appropriate, with the proviso that its a form lib
and it already exists.

The code below is lifted from a form template that allows a form
instance to delete itself from one library and write itself to
another. You won't need the delete because you're replacing the submit
and, once a particular instance exists in the destined library, a
simple save after editing works fine....I don't remember anymore where
I originally lifted this code but fwiw:

// move form to new folder

var fSuccessful = false;

// Set the URLs of the file to submit here.
var strUrlDest = "http://yourpathgoeshere" +
XDocument.DOM.selectSingleNode("//my:myFields/my:DraftTitle").text +
".xml";

try
{
// Create an xmlhttp object.
var oXmlHttp = new ActiveXObject("MSXML2.XMLHTTP");

// See whether the document with the same name already exists
in the Windows SharePoint Services (WSS) document library.
oXmlHttp.Open("HEAD", strUrlDest, false);
oXmlHttp.Send();

// No document with the URL has been found. Continue to
submit.
// If you must replace the original file, you must call
// oXmlHttp.Open("DELETE", strUrlDest, false) to delete the
document
// in the WSS document library.
if (oXmlHttp.Status == 404)
{
// Put the document in the WSS document library.
oXmlHttp.Open("PUT", strUrlDest, false);
oXmlHttp.Send(XDocument.DOM.xml);

// A 200 status code or a 201 status code indicates that
the form has been submitted successfully.
if (oXmlHttp.Status == 200 || oXmlHttp.Status == 201)
{
fSuccessful = true;
}
}
}
catch (ex){}

if (fSuccessful)
{
XDocument.UI.Alert("This Agenda Item has been successfully
created.");
eventObj.ReturnStatus = true;
}
else
{
XDocument.UI.Alert("Document couldn't be saved to the
AgendaItems library.");
eventObj.ReturnStatus = false;
}
 

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