in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

This Blog

Syndication

All About SharePoint - S.S. Ahmed - MVP Microsoft SharePoint

All About SharePoint, as the name suggests, is all about SharePoint. It has articles, tutorials, source code, FAQs, and tips about SharePoint, InfoPath, C#, Microsoft Office, SQL Server, XML, etc.

Submitting InfoPath form to two locations (DB and SharePoint)

Yes, it is possible to submit InfoPath form to two locations. Create two data connections. One will submit data to database and the other will link to your SharePoint library. Create a rule that will use both data connections when a user hits the submit button.

1. Select Tools > Submitting Forms
2. Click Rules
3. Add a Rule
4. Add two actions: Submit using database connection and Submit using SharePoint connection.
5. Save the settings
6. Publish your form in SharePoint.

Now when user hits the “Submit” button, data from InfoPath form will go to the DB and form will be saved in SharePoint as well.

-SSA

Published Sep 23 2005, 07:59 PM by ssa
Filed under: ,

Comments

 

vivek said:

Does this support for Infopath 2007?

While adding action it shows for database connection in dropdown but it does not give sharepoint connection option in dropdown menu.

Thanks

September 12, 2007 2:23 AM
 

ssa said:

hi Vivek

This post was written for InfoPath 2003. In InfoPath 2007, you can still post to two connections but you are right, the drop down doesn't show two separate options. It only shows one data connection option. You will have to create two connections, both of the type "data connections", one will submit to a SharePoint library, the other will submit to a web service. Using web service, you can send data to the database.

-SSA

September 13, 2007 1:03 PM
 

ssa said:

hi Vivek

This post was written for InfoPath 2003. In InfoPath 2007, you can still post to two connections but you are right, the drop down doesn't show two separate options. It only shows one data connection option. You will have to create two connections, both of the type "data connections", one will submit to a SharePoint library, the other will submit to a web service. Using web service, you can send data to the database.

-SSA

September 13, 2007 1:03 PM
 

Vivek said:

Thanks Ahmed !!

September 17, 2007 7:20 AM
 

Vivek said:

Hi Ahmed

Thanks for your suggestion. Can you please tell me in brief how to implement this. Do I need to write code for its implementation.

September 17, 2007 8:30 AM
 

ssa said:

Hi Vivek,

1. Create a new InfoPath project and select database option when creating the form. It will show you 5 options including database, webservice, blank, etc. Select database option and click Ok.

2. Next it will ask you to select a database. Now select a database. It will automatically create a data connection for you.

3. Now go to the submit options and create a connection that would submit data to a SharePoint library.

You may have to do some tweaking to make sure that data is being submitted to both db and SharePoint. I dont think you will have to write any code for this. Simple rules and submit options will solve your problem.

Regards

SSA

September 17, 2007 8:58 AM
 

Vivek said:

Thanks once again !!

Regards

Vivek

September 18, 2007 12:06 AM
 

Gunjan Grover said:

HI,

can any one help me out in creating a new folder in a sharepoint library on submitting a form.

Thanks in advance

Regards,

Gunjan

September 26, 2007 1:06 AM
 

galina said:

One more question please.

Web service that will be used to submit data to db: can it live on any server or it has to live on the same server where Sharepoint is installed?

Thanks a lot for your help

September 27, 2007 1:22 PM
 

Galina said:

One more question: web service used to submit data to the database- can it live on any web server or have to be installed on the same server where Sharepoint is located?

thanks

September 27, 2007 11:11 PM
 

ssa said:

Galina

The web service should be available on the SharePoint server where data is to be submitted.

SSA

September 28, 2007 10:23 AM
 

ssa said:

Gunjan

You can find the code for creating a folder in SharePoint on the net. For the other task, you can do it in the two ways:

1. By using the eventhandler  in SharePoint. When form is submitted, capture the form in the eventhandler and at that time create a folder.

2. Implement the functionality to create the folder in the form itself. for example,

In the internalstartup(), add the following:

EventManager.FormEvents.Submit += new SubmitEventHandler(FormEvents_Submit);

Then use following code to submit:

 public void FormEvents_Submit(object sender, SubmitEventArgs e)

       {

if (e.InputParameters.ContainsKey("XmlLocation"))

           {

                string Location = e.InputParameters["Source"].ToString();

               Location = Location.Substring(0, Location.IndexOf("/", 8));

               _DocLibLocation = Location + e.InputParameters["XmlLocation"].ToString();

           }

           else

           {

               _DocLibLocation = e.InputParameters["SaveLocation"].ToString();

           }

/////////////////

                   FileSubmitConnection SubmitConnection = (FileSubmitConnection)this.DataConnections["SubmitForm"];

           SubmitConnection.FolderUrl = _DocLibLocation.Substring(0, _DocLibLocation.LastIndexOf("/"));

           SubmitConnection.Execute();

                   e.CancelableArgs.Cancel = false;

               }

Create "SubmitForm" data connection before using the above code. SubmitForm dataconnection will simply submit your form to the SharePoint document library.

September 28, 2007 10:33 AM
 

Gunjan Grover said:

SSA,

Thanks a lot for the solution, but the problem is this that for eventHandling too i need to do scripting either in javascript or VBScript, can you please help me out with that?

October 2, 2007 10:45 PM
 

Gunjan Grover said:

Moreover i tried to do it in javascript... the code is:

function XDocument::OnSubmitRequest(eventObj)

{

// If the submit operation is successful, set

// eventObj.ReturnStatus = true;

// Write your code here

//Create string objects for each field we will use to modify the FolderUrl

var xnLocation = XDocument.DOM.selectSingleNode("my:myFields/my:strLocation").text;

var xnFolderName = XDocument.DOM.selectSingleNode("my:myFields/my:strFolderName").text;

var fc = XDocument.DataAdapters["SubmitForm"];

fc.FolderURL = xnLocation + "/" + xnFolderName;

//Execute the submit connection

try

{

   fc.Submit();

   eventObj.ReturnStatus = true;

}

catch(ex)

{

   var txt = ex.description;

   alert(txt);

   //eventObj.ReturnStatus = false;

}

}

but it throws an exception that folder doesnot exist.

Any comments??

October 2, 2007 11:56 PM
 

Amitabh said:

Thanks a lot Ahmed, this helped me a lot !!!

October 30, 2007 6:53 AM
 

honeyflower said:

SSA

can you please help ,me on infopath..how i can save data from infopath form to an email

thanx

:)

January 4, 2008 2:31 AM
 

Smart said:

hi

please can any one help me to find code that i can Submit infopath form to sharepoint list

Thankx

January 4, 2008 2:45 AM
 

ssa said:

1. Submitting form to email is easy. All you have to do is create a connection that would submit the form to an email address. Nothing fancy!

2. Submitting to list: Through UI, the process is same as mentioned above. Using the wizard publish the form to a SharePoint list. If you are talking about doing it programmatically then let me know. I gave that code before to some one. See my previous comments above. You will find the code.

January 5, 2008 3:16 AM
 

Smart said:

SSA

thankx for answring my Question ...the problme the code ..its not working with me...other things that i weander why when i use two button in the same form but i cant use different function...for example if i want to use one button to Submit to sharepoint and other button to email..why i cant used it....can you tell me if there are any why to solve this problme..

my regard

Smart

January 6, 2008 4:16 AM
 

Richard Love said:

Hi SSA,

My company has several WSSv3 Form Libraries containing data captured via InfoPath.  Is there a simple way to pull this data out into MS Access?

The libraries use a single form template and contain Master/Child data.

Thank you so much,

Richard Love

richard.love@stiefel.com

February 3, 2008 1:01 PM
 

ssa said:

Smart,

First let me apologize for replying late. I am sure you would have solved your problem by now. Yes, it is definitely possible to submit to two locations using two buttons. Bind each button with a different data connections, that is it!! You need two data connections to submit to two locations!

Regards

SSA

February 3, 2008 8:32 PM
 

ssa said:

Dear Richard,

Yes, you can export data from the SharePoint list or library and I am sure you knew about it. I believe you want to know if exporting data in bulk is possible or not. It's not possible out of the box but you can do it programmatically. I dont have any links handy but I am sure you will be able to find articles on other blogs, etc. If I found any links, will let you know.

Regards

SSA

February 3, 2008 8:41 PM
 

Azhar said:

Hi,

      Is it possible to submitt the form data to a sql server data base?? Actually i am having a form which i have published to a share point portal now my task is that to bring the data present in that form to a sql server data base, what i have done is that i have created a table with corresponding columns in database(local host) and i have given data connections and all, but still after publishing it to portal when i submitt the form it is saying sucessfully submitted but when i checked my table, data is not getting uploded....

any help regarding this issue of "how to get form data in to a database" will be highly appreciated...

Best Regards,

Azhar

February 14, 2008 12:52 AM
 

ssa said:

Azhar,

did you create two data connections? You can also do this programmatically if you like (that is to store the data in the db).

March 22, 2008 11:07 PM
 

Orchid said:

Hi SSA

You know if is posible two submit the same form several times??

I have a form, and a dropdownlist with names, when I click submit i want to save the form for all the names in the list for example:

My list = A, B, C

My form = a.xsn, b.xsn, c.xsn.

I put a button with submit in code, and a while for the submit,execute, but I am only obtaining one form with the first name (a.xsn) I already debug the code and doesn´t show any error.

You have any ideas??

Thanks

Orchid

April 17, 2008 5:00 PM
 

ssa said:

Orchid,

You can do it programmatically. Call the submit functionality for each of the list's items.

SSA

April 27, 2008 7:51 PM
 

Brij said:

Hello SSA,

Is it possible to submit InfoPath form data to MS Access database on local computer?

Here is what we would like to achieve:

1. Design InfoPath form and publish it to SharePoint Form Library.

2. When any SharePoint user submits InfoPath form, the data should be submitted to MS Access database on my local computer.

3. I have designed the InfoPath form and created MS Access database on my computer, created a data source to connect InfoPath form to MS Access database and it works fine for me but other SharePoint users are not able to submit InfoPath form data to MS Access database on my computer.

How can we allow other SharePoint users to submit InfoPath form data to MS Access database on my computer?

August 22, 2008 2:45 PM
 

Brij said:

Hello SSA,

Is it possible to submit InfoPath form data to MS Access database? If yes, could you please explain how?

We want to publish InfoPath form to a SharePoint site and we want to submit that form to MS Access database residing on one of the computers in the network. If I publish InfoPath form to a SharePoint site, I can submit InfoPath forms to MS Access database on my computer but other users can not.

We can achieve this for submitting InfoPath forms to SQL server but we would like to submit it to MS Access database.

Thanks in advance for all your help and support.

-Brij

August 28, 2008 7:05 PM
 

ssa said:

Brij,

If DB and InfoPath are on the same computer it will work for you only but if you want network users to have access to the form then you will have to publish the form to a shared location. Similarly, the DB should be put in a shared network location otherwise the form will not work. Create a network location, give appropriate rights to the folder and place the DB in this folder. Remember, once this is done you will have to set permissions for the DB also otherwise you will get an error. Form should also be published to a shared network location.

Good luck

SSA

August 31, 2008 10:42 PM

Leave a Comment

(required )  
(optional )
(required )  
Add

About ssa

MOSS MVP - Over 8 years experience. 4 years SharePoint experience!

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts