Using SharePoint Web Services to Fill Out an InfoPath Form

Problem

When filling out forms users tend to use nicknames, initials, or non-given names to represent their birth names. If the form is an official document then this is not acceptable. To fix this issue, the creator of the form can automatically fill in the name portion of the form with the name of the person who is filling out the form. This can be accomplished using web services.

Solution

This solution will show you how to automatically fill in the name of the person filling out the form. For example purposes I will use the Travel Request Form to demo the solution.

Open your InfoPath form in designer view.


Creating Data Connection

First a connection needs to be made to web services. To do this click on Tools-> Data Connections...

A new window will open like the picture below. Click On A dd...

Select the radio button next to R eceive data. Then click N ext >

Select the radio button next to Web service. Then Click Next >

data connection 4

Next we are asked to input the URL of the web service. You may be wondering what exactly is the web service. A quick and simple definition is that it is a way to grab information from SharePoint remotely to be used in web applications, forms, etc. For more information on what information can be accessed using web services check out this link: http://msdn.microsoft.com/en-us/library/bb862916%28office.12%29.aspx .

The URL to access web services is: http://address of sharepoint site/_vti_bin/UserProfileService.asmx . So for instance if the address of my SharePoint site is http://mycompany.com then to access web services I would use http://mycompany.com/_vti_bin/UserProfile.asmx?wsdl . We are putting UserProfile at the end because this is the service that pulls the user information from SharePoint. See the link above for other services. If you type the address above into a browser you will see something similar to the below picture...

Click N ext >

Next we are presented with a list of methods to choose from. Select the GetUserProfileByName method and click N ext >.

At the next screen leave the default value and click N ext >

Click N ext at the next screen. Do Not check the check Box.

Lastly you can leave the default name that appears on the last screen. Make sure to check the box next to "Automatically retrieve data when form is opened". Click F inish.

We have now completed creating a connection to the web service. Now the fun really begins.

Accessing the Web service

On your form right click on your name field and select Text Box Properties. Click on the fx button.

Next we are provided with the Insert Formula box. Click "Insert Field or Group"

In the Data Source box change the drop down from "Main" to "GetUserProfileByName" Note: If you changed the name of the data connection on the last step of the creating the data connection then your drop down box will reflect the name you changed it too.

Drill down to the "Value" item... See the picture below.

Next click on F ilter Data... We have to filter the data in order to choose from the 46+ possible values of the GetUserProfileByName. Some possible values available are: FirstName, LastName, Office, etc. In our case we need the FirstName.

Note: There is not a value for "FullName" so we will have to concatenate or put together the FirstName and LastName to make the "FullName". More on that to come.

On the Filter Data Screen click on A dd...

Now we need to tell InfoPath what to filter for.

In the first drop down box select "Select a field or group..." Drill down until your screen resembles the one below. Then Click Ok

Leave the middle box set to "is equal to". Next select the last drop down and select "Type Text..." Type "FirstName" in the box. This is the name of the property we are filtering for.

Your screen should resemble the following... Click Ok

Click OK on the Filter Data Screen

Your screen should resemble the one below. If it doesn't please go back and check where you made a mistake.

Click Ok until you get back to your form. If you preview the form you should see the First Name of the user in the box. However, we still need the last name.

To accomplish this we will need to write a function. Now don't freak out. We are going to let InfoPath do it for us.

Our function will resemble the picture below...

If you go back up to the step where we clicked "Insert Field or Group.." Instead we will first click Insert Fu nction... From here click all on the left hand column and then click "concat" on the right hand column. Click OK.

Now we have the box with a formula similar to the one we need.

Double click the first field where it says to "double click to insert field"

Follow the steps to filter for the FirstName. When you double click you will see what step you are to follow above. Once you ge the FirstName click on the next double click to insert field item and do the LastName.

Preview the Form and you should see something that resembles the below picture.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值