This question came about today on twitter via Erica Toelle. My fellow Tribridge colleague Chris Quick showed me this a while back. This tutorial covers the process of creating a submit button with rules for a InfoPath 2007 browser-based form.
Add a button to your InfoPath web-based form. Double-click the button and change the label to Submit. Select the Rules and Custom Code action from the Action drop down. Click on the Rules button to begin building your rules.
The Rules dialogue box will be empty. When we are done we will have created two common rules for a submit button, which are pictured below.
To create the Set File Name rule, click the Add button to create a new rule. Give your rule a name (Set File Name in this example), then select Set Condition. Choose the FileName field and is blank for the condition. Click OK. We are creating this rule to automatically give the form a file name only when it is first submitted. If a user is modifying an existing form, it will bypass this rule.
Click the Add Action button. We are going to set the file name’s value with this action. It will look like the screen shot below when we are done.
Choose the Set a field’s value option from the action drop-down. The choose the FileName field. The picture below also shows the formula that appends the exact time the form was submitted to the file name (this ensures a unique file name).
Here’s how we create that formula. Within the Value section, click the fx button. Click the Insert Function button.
Choose Date and Time from the categories and select the today function. Click OK.
Click OK in the Action dialogue box. We are done with our first rule.
Create another rule to handle submitting and closing the form. I named the rule Submit and Close. No need to set condition on this rule, just go to Add Action. We will create two actions (pictured below). One will submit the form and the other will close the form.
Select the Submit using a data connection action.
Leave the Main submit data connection. Click Ok.
Add another action. Select the Close the form option. You will get this prompt if you are creating a browser-based InfoPath form.
Click Ok. Save and publish your form to test it out. Now you should have a functioning Submit button that creates a unique file name, and automatically closes the form.