Problem: you want to use a text field in an InfoPath form to create the filename but you need a way to automatically remove spaces in the text string and replace with underscores.
Solution: Use the translate function.
Version: InfoPath 2010
- Open your data connection that is set to submit your form. Click the fx button next to File name:
- Click the Insert Function box on the dialog that displays:
- Select Text > Translate and click OK:
- The following will display:
- Click in the first link and select the field that you are using to create your filename (here I am using Filename, which is a hidden field that uses a rule to create the fields data by adding the JobTitle field underscore the date/time field. I did this so I could create a rule that allowed users to submit the form more than once without the filename recalculating the date/time for each submit…)
- In the next link, type: " " quote space qoute.
- In the last link, type: "_" quote underscore qoute
- Click Ok and Finish and then save your form, publish and test. Here is what my test file looks like. I typed in Web Producer as the job title, and the Filename field was formed by adding JobTitle_date/time:
Program: InfoPath 2010 (2007 form template)
I spent the best part of two days trying to figure out the following; hopefully it will prevent someone else from wasting a bunch of time trying to figure out the same thing.
So I have a form in InfoPath where I want to make some fields required only if another field is selected first. I created a validation rule that appeared to do what I wanted until I tried to submit the form. The conditionally required fields were outlined in red even though they contained data and the form refused to submit. After digging around a bunch of InfoPath dev forums, I kept seeing the same reference to “add a rule making the field blank”. Here are the steps to creating a conditionally required field in InfoPath (I am using InfoPath 2010 so the exact directions may need to be tweaked for 2007 users):
- Select the field that should be conditionally required. In the Rules pane, select New > Validation. Name the rule.
- Under Condition, click on the None link. You will be adding two conditions. The first condition is:
(field that determines whether or not the other field is required) (is equal to) (True)
This assumes the first field is a checkbox. If you have radio buttons with a specific choice, like Yes and No, make sure the radio selectors have values:
(field that determines whether or not the other field is required) (is equal to) (Yes)
- Click the Add button to add a second condition:
(field that should be optionally required) (is blank)
- Click OK. Here is what the completed rule should look like:
- In the ScreenTip field enter “Required“
- To test your form, click the Preview Form button in the ribbon. The conditionally required field should display as not required until the field that makes the field required is selected. The field should now display a red asterisk indicating it is required. Once data has been entered and the focus removed from the field, the form should show no validation errors.
What the fields look like on load:
Selecting the field that sets the other field to be required:
After data has been entered into the field and focus has left field: