InfoPath form templates in MOSS are widely used because there are many reasons that empower both servers.
The most common situation is that you need to pick-up some user information from MOSS and show / manipulate it on an InfoPath form. There are a few possible ways to make it work, with or without coding. The most powerful thing is by using web services provided by MOSS.
To be able to use web services in InfoPath, you should create a new Data Connection (Tools-> Data Connection). When the wizard starts, define what you would like to do with the data: submit or receive. Select Web services as a source of data and define the web service’s location. For getting user profile information (email, phone number, preferred name, etc) use MOSS services located at http://MOSSServerName/_vti_bin/UserProfileService.asmx.
- This service is not available if you are using Windows Share Point Services but only Microsoft Offices SharePoint Server.
- Some of available public methods are listed below:
- AddColleague
- AddLink
- AddMembership
- AddPinnedLink
- CreateMemberGroup
- CreateUserProfileByAccountName
- GetCommonColleagues
- GetCommonManager
- GetUserLinks
- GetUserProfileByGuid
- GetUserProfileByIndex
- GetUserProfileByName
- ModifyUserPropertyByAccountName
- RemoveMembership
- UpdatePinnedLink, etc.
Moving forward, you can take the profile data for any current or other MOSS user. For users currently logged on, you should be able to pick-up some profile info when the form is loading. For non-current users, you have a lot different cases and you can pick data on the field value changed or drop down list value selected or something else.
If you need to handle some of the available events, you should have VSTA installed (Visual Studio Tools for Applications). If you do not have it, you will not be able to create event handlers at all. To enable it, find Microsoft Office in list of Add/Remove programs. Select Change option and add find those tools for InfoPath. Select the option to install it.
Now you can create event handlers by selecting a control, right click on it, then Programming and selecting the desired event. The most interesting case is if you have a drop down list with a few names and you would like to send an email to the selected one. Before we continue, just to note that the drop down list item has a Value and a Display Name. This can give us the possibility to hide non user-friendly data. So, if you decide to get email defined in MOSS for selected user, assign the Account Name as Value for each item in the drop down. Display value can be as you wish…
When VSTA is running, add reference to UserProfileService and name it. Code in the event handler should look like:
XPathNavigator XPathNav = MainDataSource.CreateNavigator();
ServiceReferenceName.UserProfileService profile = new ServiceReferenceName.UserProfileService();
profile.UseDefaultCredentials = true;
profile.PropertyData[] userProperties = null;
try {
userProperties = profile.GetUserProfileByName(SelectedDDLValue);
}
catch { }
if (userProperties == null || userProperties.Length == 0) {
return;
}
for (int i = 0; i < userProperties.Length; i++) {
XPathNavigator node = null;
case “workemail”:
node = XPathNav.SelectSingleNode(“/my:emailField/my:userEmail”, NamespaceManager);
break;
default:
continue;
}
ServiceReferenceName.ValueData[] values = userProps[i].Values;
if (values.Length > 0) {
if (node != null && string.IsNullOrEmpty(node.Value)) {
node.SetValue(values[0].Value.ToString());
}…
The email field can be hidden or visible, it depends on what information you would like to share with the user.
- In some cases, you can experience that drop down list events do not react as you expect. Try to avoid this by setting “Always Postback” option on drop down list property.
VN:F [1.0.8_357]
Rating: 7.7/10 (3 votes cast)