Button to do both, save and submit - InfoPath Dev
in

InfoPath Dev

Button to do both, save and submit

Last post 12-04-2008 05:43 AM by Anuma. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 12-04-2008 02:10 AM

    Button to do both, save and submit

    Hi folks,

    This is probably quite simple though i'm  still new to InfoPath forms.

    The Infopath forms are filled in by users and first the submit button is pressed and then the form is saved to a sharepoint library.  The forms information sometimes go out of synch with the values in the database because a user might forget to save a form when updating and when they reopen and update, they will get an error.

     I would like to find a way to have one button that will do both, submit the values go the database and save it to the form library as well.

    Does anyone know how I could achieve this?  Thanks for any help I receive.

    ____________________________________

    Take a deep breath phsssssssssss
  • 12-04-2008 02:40 AM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Button to do both, save and submit

    Hello,

    If you want to submit the form to database and SharePoint using one button then you should write the code for both submissions code in one button. Whenever user clicks on that button it will submits to SharePoint and Database.

  • 12-04-2008 03:22 AM In reply to

    Re: Button to do both, save and submit

    Thanks for getting back to me.

     I understand that I will have to use code to submit and then save, my problem is that I don't know how to. Do you know of an article or code that could help me do this?

     Thanks.

    ____________________________________

    Take a deep breath phsssssssssss
  • 12-04-2008 05:04 AM In reply to

    Re: Button to do both, save and submit

    Hello

     

    Write the below code on onclick event

    Code for Submitting to DataBase 

    try

    {

    string empName = thisXDocument.DOM.selectSingleNode("/my:myFields/my:EmpName").text;

    string empID = thisXDocument.DOM.selectSingleNode("/my:myFields/my:EmpID").text;

    SqlConnection dbConn = new SqlConnection("Server=Server22;Database=Training_Madhuri;Integrated Security = SSPI");

    SqlCommand nonQueryCommand = dbConn.CreateCommand();

    dbConn.Open();

    nonQueryCommand.CommandText =
    string.Format("insert into Emp (id,EmpName,Department)values (" + id + "','" + EmpName + "','" + Depatment + ");

    nonQueryCommand.ExecuteNonQuery();

    }

    catch (Exception ex)

    {

    thisXDocument.UI.Alert(ex.Message);

    }

     

     

    Code For Submitting to SharePoint:

    DAVAdapter SharePoint = (DAVAdapter)thisXDocument.DataAdapters["SharePoint Library Submit"];

    SharePoint.FileName = fileName;

    SharePoint.FolderURL = SharePointURL;

    SharePoint.Submit();

     

              
    Madhuri
    http://www.ggktech.com
  • 12-04-2008 05:43 AM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Re: Button to do both, save and submit

    Anuma Chinthapalli /
    http://www.GGKTech.com
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.