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: