Promote two fields to a single SharePoint or Database column/field.
This article demonstrates how to configure an InfoPath form to display an optional text box for the user to enter a custom value if not available from the list of options. A separate field in the main data source of the InfoPath form will be used to store the value of the selected option, or the custom value if supplied by the user. Rules are set up to set the value of the separate field in the data source when an option is selected or when a custom value is entered into the text box.
Conditional formatting is also used to hide the text box until the user selects "Other" from the list of options.
Process:
Set up the Initial InfoPath Form
1. Design a new form template using InfoPath 2003 or 2007
2. From the Task Pane (CTRL+F1), open the Controls toolbar
3. Double click, or drag an Option Button control onto the default view of the form template. Enter the number of options required (remember to add an additional option for "Other").
5. Enter a Field Name for the field. Note: You only need to set the field name on one of the options for it to be applied to all.
6. Enter the value which will be used when this option is selected for the "Value when selected".
7. Press Ok
8. Repeat Step 6 for each option. Enter "Other" as the value when selected for the final option.
Add Conditional Formatting to hide the "Other" text field when it is not required
11. Right Click on the "Other" text field control on the form template.
12. Select Conditional Formatting...
13. Press the "Add..." button to add a condition
14. Select the "Options" field created in step 3, "is not equal to" for the condition, and a text value of "Other" to test against (Select "Type text..." from the options).
15. Tick the "Hide this control" option for the formatting to be applied.
The "Other" text field will now only be visible when the user selects the "Other" option radio button.
Create Rules to set the value of the separate text field to be submitted with the form
16. Click "Add.." to create a new rule for this field.
17. Set the condition to the "Options" field, "is not equal to", Type "Other" as the value to test against.
18. Click the "Add Action..." button.
19. Select "Set a field's value" from the list of Actions
20. Select the "OptionSelected" field from the Main Data Source for the "Field" option
21. Select the "Options" field for the "Value" option.
This rule will now set the OptionSelected field to the value selected by the user if "Other" was not selected.
22. Right Click on the "Other" text field and select "Rules...", Click "Add..." to create a new rule for this field.
23. Set the condition for the rule to the "Options" field, "is equal to", and "Other" for the value.
24. Click the "Add Action..." button.
25. Set the Action to "Set field's value"
26. Set the "Field" option to the "OptionSelected" field
27. Set the "Value" option to the "Other" text field (current).
28. Right click on the OptionSelected field in the Main Data Source and set the default value to the default value of the "Options" field.
Conclusion
When a user selects one of the options available, but not the "Other" option, the value selected is set as the value for the separate text field created using rules. When the user selects "Other" from the options, the "Other" text field will become visible for the user to enter a custom value. When the user enters a custom value into the "Other" text box, rules are also used to set the selected value as the value for the separate text field in the main data source.
The separate field will always contain the value selected or manually entered by the user, which when promoted to a SharePoint or database column instead of promoting both the option button control and the "Other" text box. The separate field does not need to be added to the form template, as the value of the field will be set using rules when a user changes a value when completing the form.
No comments:
Post a Comment