InfoPath 2007

Custom Save Button for Web Enabled Form

I recently found the need to submit and save Infopath 2007 browser enabled form data. The submit is very straight forward when using browser enabled forms, but the ability to save the form is not so straight forward or so you might think. After thinking for a little while on how to work around the save capability I found a very simple process to allow users to Submit and Save InfoPath Browser enabled forms back to the SharePoint Library without any custom code.

Designing the Form

  • Begin by creating an InfoPath 2007 form with a button and some text box control(s).clip_image001
  • Add an additional Data Source called submitFormNameclip_image002

    Add a Data Connection

    Create the Data Source Connection that will allow the form to be submitted to the SharePoint site using the following steps.

     

  • Click on the Manage Data Connections… and then click the Add buttonclip_image003
  • Select Create a new connection to: and Submit Data then click Next >clip_image004
  • On the next screen Select a destination for submitting your data choose the To a document library on a SharePoint site then choose nextclip_image005
  • Now provide a URL to the document library you want to submit your data to. In the next to the file name textbox click on the fx button. Click on the Insert Field or Group… button and select the submitFormName field.clip_image006
  • Click the OK button on the Select a Field or Group window and on the Insert Formula Window. On the data connection wizard check the Allow overwrite if file exists option. Click Next >.clip_image007
  • You can now provide a custom name for your data connection then click Next >.
  • Click Close on the Data Connections windowAdd the actions to the Custom Button
  • Double Click on the button control added to the InfoPath formclip_image008

    Select Rules and Custom Code for the Action and provide a label and control ID, if desired, of your choice.

    Click on the Rules… button and then click on the Add button in the Rules Window.

    clip_image009

    Screen clipping taken: 4/29/2009, 4:59 PM

    Name this rule Set File Name and click on the Set Condition… button. For the Condition check if the submitFormName is blank. Click the OK button.

    clip_image010

    Click the Add Action… button. For the action select Set a field’s value, for the Field select submitFormName, for the Value use, using the fx builder use the expression concat(“Account Request – “, now()) then click OK.

    clip_image011

    Click OK on the Rule Window. Now click on the Add… button again on the Rules window. Name this rule Submit Form and do not specify a condition. Add an action to Submit using a data connection and select the Data connection created in the last section.

    clip_image012

    Click the OK button on the Action and Rule windows.

    Click the Add… button on the Rule Window. Name this rule Close Form and do not specify a condition. Add an action to close the form.

    clip_image013

    Click Ok on all of the windows until you are back to the InfoPath form designer.

    Now publish your form to the SharePoint site library that was specified in the Data Connection section. Once the form is published go to that library and choose Settings->Form Library Settings

    clip_image014

    Under the General Settings choose Advanced settings

    clip_image015

    In Advanced Settings under the Browser-enabled Documents choose Display as a Web page and then click OK

    clip_image016

    This will force the InfoPath form to be opened using Form Services.

    Now complete a form and submit it. Then click on the form, change a value and submit again. You should see your changes applied after you submit.