The last project I was working on before I left my last job was a complex InfoPath “app” that had conditional forms, logic, workflows-the works. I was super proud of what I built because it really was a little application, and I built it, and I am no programmer. Since I work exclusively with internet-facing sites at my current gig, I have had to say bye to InfoPath, but hearing that it is being retired makes me a little sad. It will be interesting to see what new solution Microsoft is coming out with to take InfoPath’s place. What I really want to see in regards to SharePoint is a internet-only version with features that make sense for anonymous access sites. It is so painful to not be able to use so much of the power of SharePoint due to those features needing authentication.
Part Two: Using the UserProfileService to Auto-Fill Fields
Today we will be using the UserProfileService to automatically populate the following fields based off the current logged user:
- My Name
- My Email
- My Title
- My Department
- My Manager
- My Manager’s Email
- My Manager’s Title
If you haven’t already connected to the webservice, follow the instructions in Part One: Connecting to the UserProfileService web service in InfoPath
Once you are connected to the service, create a new InfoPath form and add the fields listed above. Your Form should look something like this:
Double-click the My Name field. Select Control Properties from the Properties tab in the ribbon. Under Default Value, click the fx button:
Click Insert Field or Group:
The Select a Field or Group dialog will display. Select GetUserProfileByName from the Fields dropdown:
Expand out the dataFields node until you get to Value. Select Value and then click Filter Data:
Click Add on the Filter Data dialog:
Under the Value dropdown, select Select a Field or group. Select Name from the Select a Field or Group dialog. Click OK:
In the third dropdown in the Specify Filter Conditions dialog, select type text and then type in PreferredName:
Click OK and then click OK on all the open dialogs. You will then follow these same steps on each of the following fields; substitute the listed text for the PreferredName text:
- My Email: enter text Email
- My Title: enter text Title
- My Department: enter text Department
You should now have all of the My Info fields created and have default values added for each. For the manager’s section, we will add a new data connection using the UserProfileService, except when you get to the Operations screen, instead of selecting GetUserProfileByName you will select GetCommonManager:
Once the new data connection for GetCommonManager is made, select the control properties for the My Manager field, click the fx button, click Insert Field or Group. In the Fields dropdown that displays on the Select a Field or Group dialog, instead of selecting GetUserProfileByName, select GetCommonManager. Expand out the GetCommonManagersResult node and then select Name. Click OK on all open dialogs:
Follow these steps on each of the remaining Manager fields with the following substitutions in the Select a Field or Group > GetCommonManagerResult node:
- My Manager’s Email: select Email
- My Manager’s Title: select Title
Save your file and preview. your result should look like this:
Stay tuned for Part Three: Using the GetCommonManager function to display a user’s supervisor hierarchy.
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.
I have been out of town for almost two weeks now. The last week of August, I went to Nashville for Infopath training. The day after I got back, I had to evacuate for Hurricane Gustav. I just got back home this morning. I’m trying to remember my training… 😉
I went to the InfoPath class offered by SharePoint Solutions. It was three days long and covered InfoPath, SharePoint, and Workflows. The instructor was very nice and knowledgeable. I have a much better understanding of how to use IP to create forms and even mimic applications. I really thingk that IP will become a primary means for my group to create small apps, as most of the apps we build are just web versions of print forms. The savings in development time will be huge. I will post more as I remember-still have hurricane brain fog 😉