Add a rule InfoPath 2007

Author: mety Labels::



When you design a form template, you can use rules to automatically display a dialog box, set a field's value, query or submit to a data connection, switch views (view: A form-specific display setting that can be saved with a form template and applied to form data when the form is being filled out. Users can switch between views to choose the amount of data shown in the form.), or open or close a form in response to certain events and conditions. The events can include a change to a particular field or group in the data source (data source: The collection of fields and groups that define and store the data for an InfoPath form. Controls in the form are bound to the fields and groups in the data source.), the click of a button, the insertion of a repeating section (repeating section: A control on a form that contains other controls and that repeats as needed. Users can insert multiple sections when filling out the form.) or row in a repeating table (repeating table: A control on a form that contains other controls in a table format and that repeats as needed. Users can insert multiple rows when filling out the form.), or the opening or submission of a form. The conditions can include calculations, XPath (XML Path Language (XPath): A language used to address parts of an XML document. XPath also provides basic facilities for manipulation of strings, numbers, and Booleans.) expressions, user roles (user role: A predefined category that can be assigned to form users based on job title or some other criterion. Roles are typically used to present customized versions of a form to different types of users.), and whether the value of a field is blank, is within a specified range, equals the value of another field, or starts with or contains certain characters.
You can also add multiple actions for each rule. For example, you can add a rule that displays a dialog box message to let the user know that a new form view will appear, changes the view of the form, and then uses a data connection when a user fills out a control that is bound to a field.

When you need to apply business logic to your form template, you can use rules. A rule can do the following:
  • Show a dialog box message You can add a rule to show a dialog box to a user if a certain condition in the form is met. For example, you can display a message in an expense report form if the user enters a value that exceeds a specific amount.
  • Show a dialog box expression You can add a rule to display the results of an XPath expression that calculates the values of different fields on the form. For example, you can use this action in the middle of several rules that are used to perform a complex calculation. You can use this action to verify that the calculation is working correctly by monitoring each change that occurs in the values during the calculation.
  • Switch views You can add a rule to navigate through several views or to change the view of a form that is based on the user role that is associated with the user who opens the form. For example, you can add a rule to a button that allows the users to go to the previous or next view when they click the button.
  • Set a field's value You can add a rule that calculates the value of a field. For example, you can add a rule to a field that displays the project end date based on the date from another field plus a set number of days.
  • Query by using a data connection You can add a rule that sends a query through a data connection when a condition occurs on the form. For example, you can add a rule that sends a query through a data connection when a user enters his or her employee number in an expense report form.
  • Submit by using a data connection You can add a rule that submits all of the data in a form to an external data source through a data connection. For example, you can add a rule to a form template for a permit application that submits the data in the form to a Web service and a database when the user clicks a Submit button on the form.
  • Open a new form to fill out You can add a rule that opens a new copy of a form that is based on this form template or another form template. For example, you can add a rule to a form template for a permit application that does the following: If the value in a field exceeds a fixed amount, the rule opens a new form that is based on another form template that is used for both electrical and building permit applications.
  • Close a form You can add a rule that closes the form when an event occurs on the form. For example, you can add a rule that closes a form after the user submits the form and the external data source confirms that the form was successfully submitted.
Note The types of rules that you can apply to your form template depend on the controls and fields on your form template.

The rules in a control that is bound to a field are automatically applied to that field, and the rules in a field are automatically applied to the control that is bound to that field. If you bind a control to a field that contains existing rules, the rules are automatically applied to the control. If you add a rule to a control, that rule is automatically applied to the field that is bound to that control.
If you add multiple rules to your form template, Microsoft Office InfoPath runs each rule in the order that the rules appear in the Rules dialog box. You have the option to stop processing the remaining rules after you run a preceding rule.

Compatibility considerations
Although you can add a rule to your form template that displays a dialog box to your users, dialog boxes do not display automatically in forms that users fill out in a Web browser. Dialog boxes are displayed automatically only in forms that are filled out in InfoPath.

Add a rule that runs when a user opens the form

  1. On the Tools menu, click Form Options.
  2. In the Category list, click Open and Save.
  3. Under Open behavior, click Rules.
  4. In the Rules dialog box, click Add.
  5. In the Name box, type a name for the rule.
  6. To specify a condition for when the rule should run, click Set Condition, enter the condition, and then click OK. The rule will run when the condition that you specify in this step is met.
  7. Click Add Action.
  8. In the Action list, click the action that you want, and then enter the options for that action.
  9. Repeat steps 7 and 8 for each action that you want to run for this rule.
  10. To prevent any rules from running after the condition for this rule is met and the rule runs, select the Stop processing rules when this rule finishes check box.
  11. Click OK.
  12. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.

Add a rule to a control

If the control is bound to a field that has one or more rules, the field's rules are automatically applied to the control. Any rule that you add to the control is also added to the field. If you add a control to a view on a form template and then bind the control to a field with existing rules, the existing rules are automatically applied to the control. If you add a rule to a field and the field is bound to a control, the rules are automatically applied to the control as well.
  1. Double-click the control.
  2. Click the Data tab.
  3. Click Rules.
  4. In the Rules dialog box, click Add.
  5. In the Name box, type a name for the rule.
  6. To specify a condition for when the rule should run, click Set Condition, enter the condition, and then click OK. The rule will run when the condition that you specify in this step is met.
  7. Click Add Action.
  8. In the Action list, click the action that you want, and then enter the options for that action.
  9. Repeat steps 7 and 8 for each action that you want to run for this rule.
  10. To prevent any rules from running after the condition for this rule is met and the rule runs, select the Stop processing rules when this rule finishes check box.
  11. Click OK.
  12. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.

Add a rule to a field or a group

If a control is bound to a field that has existing rules, those rules are automatically applied to the control as well. Any rule that you add to the field is also added to the control.
  1. If the Data Source task pane is not visible, click Data Source on the View menu.
  2. Double-click the field.
  3. Click the Rules and Merge tab.
  4. Click Add.
  5. In the Name box, type a name for the rule.
  6. To specify a condition for when the rule should run, click Set Condition, enter the condition, and then click OK. The rule will run when the condition that you specify in this step is met.
  7. Click Add Action.
  8. In the Action list, click the action that you want, and then enter the options for that action.
  9. Repeat steps 7 and 8 for each action that you want to run for this rule.
  10. To prevent any rules from running after this rule (for the current event), select the Stop processing rules when this rule finishes check box.
  11. Click OK.
  12. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.

Add a rule when the user submits a form

You can configure your form template to run one or more rules when your user submits their form based on your form template. For example, you can add a rule to your form template that automatically submits the form to a database and in an e-mail message when a user chooses to submit the completed form. You can also add a rule to your form template that switches the form to a different view when the user submits the form.
Note Before starting this procedure, make sure that your form template has at least one submit data connection. Find links to more information about submit data connections in the See Also section.
  1. On the Tools menu, click Submit Options.
  2. In the Submit Options dialog box, select the Allow users to submit this form check box.
    Note When you select this check box, InfoPath adds a Submit button to the Standard toolbar and a Submit command to the File menu when users fill out the form.
  3. Click Perform custom action using Rules, and then click Rules.
  4. In the Rules for Submitting Forms dialog box, click Add.
  5. In the Name box, type a name for this rule that describes the submit location. For example, if you want to allow users to submit the form by using an e-mail message only if the value in a specific field is greater than $50, type E-mail submit for over $50.
  6. To set a condition that must be true before using this rule, click Set Condition in the Rule dialog box. In the Condition dialog box, set the conditions that must be true, and then click OK.
  7. In the Rule dialog box, click Add Action.
  8. In the Action list, click the action that you want to occur when the user submits a form based on this form template, and then select the appropriate options for that action.
  9. Click OK.
  10. To add additional actions, repeat steps 7 through 9 for each additional action.
  11. To add other rules, repeat steps 4 through 9 for each additional rule.
  12. Click OK.
  13. To change the name of the Submit button that appears on the Standard toolbar and the Submit command that appears on the File menu when users fill out the form, type the new name in the Caption box in the Submit Options dialog box.
    Tip If you want to assign a keyboard shortcut to this button and command, type an ampersand (&) before the character that you want to use as a keyboard shortcut. For example, to assign ALT+B as the keyboard shortcut for the Submit button and command, type Su&bmit.
  14. To prevent users from using the Submit command or the Submit button on the Standard toolbar when they fill out your form, clear the Show the Submit menu item and the Submit toolbar button check box.
  15. By default, after users submit a form, InfoPath keeps the form open and displays a message to indicate if the form was successfully submitted. To change this default behavior, click Advanced, and then do one of the following:
    • To close the form or create a new blank form after the user submits a completed form, click the option that you want in the After submit list.
    • To create a custom message to indicate if the form was successfully submitted, select the Use custom messages check box, and then type your messages in the On success and On failure boxes.
      Tip Use a message in the On failure box to tell users what to do if they cannot submit their form. For example, you can suggest that users save their form and contact someone for further instructions.
    • If you do not want to display a message after the user submits a form, clear the Show success and failure messages check box.

0 comments |

Labels

Blog Archive

Powered by Blogger.

I made these pages for me and my friends to help solving the problem we face regarding Computer & internet, if anyone wants me to answer a question or find out about some information please send me email and I will try to reply.*P.S. some of the article I wrote and the other I found on the internet I posted them in sprit of learning and shearing, please forgive me if you found something you don’t want to be in my blog, email me and I will delete them. Thank you for your interest in my pages.امل نجم Amal Nagm

banner 1 banner 2