lab environmentdownload.microsoft.com/download/6/d/c/6dc7ba75-ebfc-4e22... · web viewheader column...
TRANSCRIPT
InfoPath Forms Services 2010
Hands-on Lab
Released:
Terms of UseThis document is provided “as-is”. Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear the risk of using it.
Some examples depicted herein are provided for illustration only and are fictitious. No real association or connection is intended or should be inferred.
This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes.
© 2011 Microsoft Corporation. All rights reserved.
This document reflects current views and assumptions as of the date of development and is subject to change. Actual and future results and trends may differ materially from any forward-looking statements. Microsoft assumes no responsibility for errors or omissions in the materials.
THIS DOCUMENT IS FOR INFORMATIONAL AND TRAINING PURPOSES ONLY AND IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
2 © 2023 Microsoft Corporation. All rights reserved.
About the AuthorAuthor: Ravi VridhagiriBio: As Chief Technology Officer for OnTerra Systems, Ravi Vridhagiri
is responsible for development of OnTerra’s new product offerings, and plays a prime role in OnTerra’s technology consulting commissions. He is a Microsoft-certified Technology Specialist in SharePoint application development – with more than 12 years of experience in various technology solution design and project implementations. He has extensive experience in Microsoft technologies, specifically Microsoft SharePoint, Microsoft C#, .NET, and more. He also is a certified Project Management Professional (PMP).
Mr. Vridhagiri earned a Bachelor of Science in Mechanical Engineering from the University of Madras in India in 1999. He went on to earn a Master’s of Business Administration (with specializations in Management of Information Systems and Finance) from the Rutgers University Business School in 2009
Table of Contents
Lab Environment................................................................................................................................................................ 1
Lab Overview........................................................................................................................................................................2
Exercise 1: InfoPath Forms for Process Management........................................................................................3
Exercise 2: Forms as Sandboxed Solution.............................................................................................................26
Exercise 3: SharePoint data To and From InfoPath Forms............................................................................31
Exercise 4: InfoPath Forms to Read and Write to Line of Business (LOB) Systems...........................46
Appendix.............................................................................................................................................................................. 55
4 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Lab EnvironmentDuring this lab, you will work in a simulated environment with the following computers or virtual machines.
Computers and Virtual Machines Used in This Lab
Icon Computer Name Description
DEMO2010AThis computer is configured as a stand-alone server running Windows Server 2008 with SharePoint Server 2010, SQL Server and Visual Studio 2010
Logon Credentials
The lab environment might require you to log on to the Hands-on Lab Environment using the following credentials, unless specified differently throughout the lab manual.
Username PasswordAdministrator pass@word1
AdventureWorks Database
The AdventureWorks database is a set of sample databases that are currently available for Microsoft SQL Server 2005 and Microsoft SQL Server 2008. The AdventureWorks sample database installer is located on the DEMO2010A virtual machine at C:\AdventureWorksDB\AdventureWorks2008R2_RTM.exe and the instructions can be found in the Appendix of this document.
1 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Lab OverviewAbstract
InfoPath Forms Services is a server technology that makes it possible for users to fill out forms in a Web browser. By managing forms in a central location, you can streamline business processes. Users don't have to have InfoPath installed on their computer to fill out a browser-enabled form template, nor are they required to download anything extra from the Web. All they need is access to a browser, such as Windows Internet Explorer.
During this lab, you will perform several exercises to achieve a better understanding of the capabilities and functionality of InfoPath 2010 and InfoPath Forms Services 2010 in SharePoint 2010.
You will start by creating a process management application to help you understand InfoPath forms and InfoPath Forms Services.. You will then add .NET code within the InfoPath form to add additional functionality and learn how to publish forms to SharePoint without an administrator's assistance. You will also learn how to send and receive SharePoint data from an InfoPath form.
By the end of this lab you will have created forms that interact with other Line of Business systems.
Learning Objectives
After completing the exercises in this lab, you will be able to:
Create forms-based applications to manage business processes.
Add custom .NET code to forms and publish them as sandboxed solutions.
Create InfoPath forms to read and write SharePoint data.
Create InfoPath forms to access information from other line of business applications and systems.
Estimated time to complete this lab: 90 minutes
2 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Exercise 1: InfoPath Forms for Process ManagementScenarioIn this exercise you will learn the basics of creating an InfoPath form. You will create an InfoPath forms-based application to manage the expense reimbursement process. You will learn about the opportunities for integration between SharePoint and InfoPath and learn how to publish browser-enabled forms. You will also learn how to configure out-of-the-box SharePoint workflows to run on any submitted form and how to route forms through an approval process.
After completing this exercise, you will be able to:
Create InfoPath forms
Publish InfoPath forms as Content types and as templates
Publish browser-enabled InfoPath forms
Attach workflows to a forms library to initiate a workflow process on new forms
Task Detailed Steps
Complete these steps by connecting to the computer Demo2010a.
Create a new InfoPath Form
1. Click Start | All Programs | Microsoft Office | Microsoft InfoPath Designer
2010 Designer menu.
3 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
2. On the File tab, click New.
3. Under Available Form Templates, select Blank Form.
4. Click Design Form.
5. On the Insert tab on the ribbon, click Custom Table, and then click Layout
table.
4 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
6. In the Insert Table dialog box, set the following:
Number of columns: 2
Number of rows: 2
7. Click OK.
Design the Form by adding controls
8. On the ribbon, click the Home tab.
9. You will see a section called Controls:
10. In the following steps, you will add controls to the design canvas to create the
form. The following image shows the layout of the form that will be created.
5 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
11. Add the Employee Name field as follows:
a. On the Controls toolbar, click Text Box to add a Text Box control to
the designer.
b. Right-click on the Text Box and click Text Box Properties.
c. On the Data tab, set the Field name to EmployeeName.
d. Click OK.
6 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
12. Add the Expense Period as follows:
a. Add a From date: On the Controls toolbar, click Date Picker. This will
add a date picker to the designer.
Right-click the control and click Date Picker Properties.
On the Data tab, set the Field Name to ExpensePeriodFrom.
7 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
b. Add a To date: On the Controls toolbar, click Date Picker. This will add
a date picker to the designer.
Right-click the control and click Date Picker Properties.
Under Data tab, set the Field Name to ExpensePeriodTo.
13. Add the Business Purpose field as follows:
a. On the Controls toolbar, click Text Box to add a Text Box control to
the designer.
b. Right-click the Text Box and click Text Box Properties.
c. On the Data tab, set the Field Name to BusinessPurpose.
d. On the Display tab, check Multi-line.
e. Click OK.
14. Add a table for entering the Itemized Expense as follows:
a. On the Controls toolbar, click Repeating Table.
8 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
b. Set the Number of Columns to 5.
c. In the Task pane, you will see a nested group element has been
added:
d. Right-click on each of the elements and go to their respective
Properties.
e. Change their names as follows:
15. In the designer, right-click the ExpenseDate, click Change Control, and then
click Date Picker. You just changed the Text Box control to a Date Picker
control:
9 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
16. Similarly, in the designer, right-click ExpenseCategory, click Change Control,
and then click Drop-Down List Box. You just changed the text box to a drop-
down list box:
17. Right-click on the ExpenseCategory again, and click Drop-Down List Box
properties.
18. In List box choices section, select Enter Choices Manually.
19. Click Add.
20. Type Air Fare (Note: Typing a Value will also populate the Display name).
10 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
21. Click OK.
22. Similarly add additional items for ExpenseCategory as follows:
23. Right-click on the ExpenseAmount field.
a. Click Text Box Properties.
b. From the Data type drop-down list, select the Decimal (double) Data
type:
11 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
c. Click OK.
24. Create the Expense Total field as follows:
a. On the Controls toolbar, click Text Box to add a Text Box control to
the designer.
b. Right-click the Text Box and click Text Box Properties.
c. On the Data tab, set the Field Name to ExpenseTotal.
d. Click OK.
25. Click the Save button and save the form to your local disk as
ExpenseReimbursement.xsn
NOTE: The steps 26 to 35 are Optional
Calculate the total for the itemized expenses
26. Right-click the ExpenseTotal field.
27. Click Text Box Properties.
28. Click the fx button next to Value:
12 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
29. Click the Insert Function button:
30. From the list of Categories, select Math.
31. From the list of Functions, select Sum:
13 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps32. Click OK.
33. Back in the Insert Formula dialog box, double-click double click to insert field:
34. Expand ItemizedExpenses, expand ExpenseRows, and select ExpenseAmount.
35. Click OK on all open dialog boxes to complete this step.
Retrieve the name of the employee filling out the form
36. Right-click on the EmployeeName Text Box and click Text Box Properties
37. Click the fx button next to value.
38. Click the Insert Function button.
39. From the list of categories, select User.
40. From the list of functions, select userName:
41. Click OK on all open dialog boxes to complete this step.
NOTE: The steps 42 to 47 are Optional
Add additional formatting and validation
42. The Employee Name field should be a read-only field. To make it read only,
14 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Stepsright-click the EmployeeName text box and click Text Box Properties.
43. On the Display tab, select Read-only, and then click OK:
44. The Amount and Total Amount fields should be right-aligned. To do so, Right-
click on the ExpenseAmount TextBox control and click Text Box Properties.
45. On the Display tab set Alignment to Right.
46. Repeat the steps 37 and 38 for the ExpenseTotal TextBox.
47. Set the ExpenseTotal Textbox to Read-Only:
Create a new forms
library where the
48. Open an Internet Explorer browser window and browse to
15 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Stepsforms can be
submitted to
http://intranet.contoso.com/.
49. On the Site Actions menu, click More Options.
50. Select Form Library from the list of available templates.
51. Type Expense Reports as the name of the Forms library.
52. Click Create to create the Forms library:
Create Submit rules 53. On the ribbon, click the Home tab.
54. From the Controls select Button and add a button to the form:
55. Right-click the button and click Button Properties.
56. Change the text to Submit.
57. Click OK.
16 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
58. With the Submit button still selected, click Manage Rules from the ribbon
(Note: You will find this under Home tab):
59. In the Rules task pane, click New and select Action.
60. Type Submit Form as the name of the action.
61. Under Run these Actions, select Submit Data.
62. In the Rule details dialog box, click Add.
63. Select Create a New Connection to submit data. Click Next.
64. Select the option: To a document library on SharePoint site. Click Next.
65. Type the full path of the Forms library that you created previously
(http://intranet.contoso.com/Expense Reports/).
66. Click the fx button. Click Insert Field or Group.
67. In the Formula area, type: concat(EmployeeName, "-", today())
This will create a unique name for the submitted form:
17 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
68. Click OK.
69. Click Next.
70. Click Finish.
71. Click OK.
72. In the Rule task pane, click New and select Action.
73. Type Close Form as the name of the action.
74. Under Run these Actions, select Close the Form.
75. Click OK.
Promote the
InfoPath form fields
as SharePoint
metadata
Property promotion
enables SharePoint
to extract and store
the values of the
InfoPath form fields
as list item
metadata
This enables users to
sort or filter a list
based on the values
in the InfoPath form.
You can also use
these properties to
create list views.
76. On the Ribbon, click the File tab.
77. Select Info.
78. Click Advanced Form Options.
79. In the Form Options dialog box, choose Property Promotion.
80. Click Add.
81. Select EmployeeName, ExpenseTotal, ExpensePeriodFrom and
ExpensePeriodTo to the list of properties to be promoted.
82. Click OK.
18 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed StepsPublish the form as a
form template
There are three ways
a form can be
published: as a form
template for a
library, as a Content
Type, and as an
administrator-
approved form.
83. On the ribbon, click the File tab.
84. Click Publish.
85. Click SharePoint Server.
86. Type the location of the SharePoint site (Ex: http://intranet.contoso.com/)
87. Select Enable this form to be filled out by using a browser, and select Form
Library, and then click Next:
88. Select Update the form template in an Existing Form Library, and then select
the Expense Reports library that you had already created.
89. Click Next.
90. Click Next.
91. Click Publish.
92. Click the Save icon to save the form.
Review and test the
deployed form
93. Open a Internet Explorer browser window and browse to
http://intranet.contoso.com/expense reports
94. Click Add a new Item. The InfoPath Form will open in the browser.
95. Fill out the form and click the Submit button. The contents of the form will be
submitted to the Forms library.
NOTE: The steps 96 to 129 are Optional
Publish the form as a
Content Type
A site content type
allows a form to be
96. Go back to the ExpenseReimbusement.xsn form in InfoPath designer
97. Delete the Submit button. (Select the Submit button, and press DELETE)
98. On the File tab, click Info, and then click Advanced form Options.
99. Select Web Browser under the list of Categories.
19 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Stepsused in multiple
libraries and sites.
Publishing an
InfoPath form as a
content type enables
the form to be used
throughout the site
collection.
100. Make sure the Show InfoPath Commands in Ribbon or toolbar is checked.
101. Under Show the following commands:, uncheck all options except Save and
Close.
102. Click OK.
103. Click the save icon to save the form:
Publish the form as a Content type.
104. On the ribbon, click the File tab.
105. Click Publish.
106. Click SharePoint Server:
107. Type http://intranet.contoso.com/ as the location of the SharePoint site
collection, and then click Next.
108. Select Enable this form to be filled out by using a browser, select Site Content
Type (advanced), and then click Next:
20 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
109. Select Create a new Content Type, and then click Next:
110. Type Expense Form as the name of the form, and then click Next.
111. You need to store the form in the SharePoint site to make it available as
Content Type. Usually such forms are stored in the Site Assets library. Type in
the full path of the Site Assets library and a name for this Form
Ex: http://intranet.contoso.com/SiteAssets/ExpenseForm.xsn
112. Click Next.
113. Click Publish.
The InfoPath Form has been published as a Content Type and is available to the
entire site collection.
Create a new Library using the form Content Type
114. Open an Internet Explorer browser window and navigate to
http://intranet.contoso.com
21 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps115. On the Site Actions menu, click More Actions.
116. From the list of templates, choose Forms Library. Type in a name of Expense
Reports New.
(You are creating a form template named Expense Reports New to differentiate
it from the Expense Report forms library you created in previous steps)
117. Click Create.
118. In the newly created library, on the ribbon, click Library Tools.
119. On the library toolbar, click Library Settings.
120. Click Advanced Settings.
121. Set Allow management of content types to Yes, then click OK:
122. On the Settings page, under Content Types, click Add from existing site
content types:
123. From the list of available content types select the Expense Form content type
and then click Add.
124. Click OK.
125. In the Settings Page, under Content Types, click Form.
126. Click Delete this Content Type.
(Note: You are deleting the default content type and making the Expense
Report Content type the default)
127. Navigate to the newly created Forms library
(http://intranet.contoso.com/expense reports new)
128. Click Add a new Item.
129. Fill out the InfoPath form. On the toolbar, click Save.
22 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed StepsNote: You will only be able to save this to the parent forms library
NOTE: The steps 130 to 146 are Optional
Add workflow capabilities to the form library
130. Navigate to the forms library that you created in the earlier tasks.
(http://intranet.contoso.com/expense reports new)
131. On the ribbon, click List tools.
132. Under List, click Workflow Settings.
133. Click Add a workflow:
134. From the list of available templates, choose the Approval – SharePoint 2010
out-of-the-box workflow:
135. In the Name text box enter Expense Report Approval.
136. Check Start this workflow when the new item is created.
137. Click Next.
138. In the next screen specify other workflow settings like Assigned to (Approver),
Due Date and Duration.
23 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
139. Click Save to finish configuring the workflow.
Review and test the process.
140. Navigate to the Expense Reports New forms library.
141. Click Add document.
142. Fill out the Expense Reports form and save it.
When a new item is added by submitting/saving a new form, the workflow will
start automatically. A task is assigned to the Approver.
143. Click the drop-down list on the newly submitted form.
144. Click Workflows.
145. Notice the instance of the workflow that has initiated:
146. Click In Progress. Check the Tasks and the Workflow History sections. You will
24 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Stepssee that a task has been assigned to a Contoso user seeking approval for the
submitted expense report.
25 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Exercise 2: Forms as Sandboxed SolutionScenarioSandboxed solutions offer a way to build SharePoint applications and deploy them to a site without needing administrative intervention. In this exercise you will re-use the Expense report InfoPath template that you created in exercise 1 and learn to use managed code in your InfoPath form to sort a column in ascending or descending order. You will then learn how to publish the InfoPath form with managed code as a SharePoint sandboxed solution.
After completing this exercise, you will be able to:
Create InfoPath forms that uses managed code.
NOTE: This Exercise is Optional
Task Detailed Steps
Complete these steps by connecting to the computer DEMO2010A.
Select the Programming language.
The programming languages that are supported for the form template are either C# or Visual Basic. This requires that Visual Studio Tools for Applications (VSTA) be installed and .Net Programming support for InfoPath be enabled.
1. Right-click the ExpenseReimbursement.xsn , and click Design
2. On the ribbon, click the File tab, and then click Info.
3. In the Advanced Form options section, click Form Options.
4. In the Form Options dialog box, from the list of available categories, select Programming.
5. Select C# as the Form template code language
6. Click the Browse button and choose a project location where you would like to store the project:
26 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
7. Click OK.
Add managed Code to the InfoPath form
The repeating control that we added in the Expense Report form does not have sorting capability. When the form is submitted for review/approval, the ability to sort the submitted expense by date, amount or by category is a “nice to have”. This code sorts the rows based on the Expense Date column in the table, but you can easily modify the code to work with any column.
8. On the ribbon, click the Home tab.
9. From the Controls select Button, and add a new button control to the form.
10. Move the button to the Date header column of the repeating table.
11. Right-click the button and then click Button Properties.
12. Change the label to Date. Click OK.
13. Right-click the button again, and then click Button Properties.
14. Under Action, select Rules and Custom Code.
15. Click Edit Form Code. This will launch Microsoft Visual Studio for Applications.
16. Copy and paste the below code in the button click event.
C#
// Put the elements from the first column into an array.XPathNavigator root = this.CreateNavigator();
// Create a node iterator which contains only the values that you want to sort.// For this form, the entire table is in "ItemizedExpenses", each row is a "ExpenseRow"// and the rows are "ExpenseDate", "ExpenseCategory" and "MerchantName" respectively.XPathNodeIterator nodeIterator = root.Select("/my:ExpenseFields/my:ItemizedExpenses/my:ExpenseRows/my:ExpenseDate", this.NamespaceManager);
// Create arrays to use for sorting.string[] sortArrayWords = new
27 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Stepsstring[nodeIterator.Count + 1];int[] sortArrayKeys = new int[nodeIterator.Count + 1];int arrayPosition = 1;
// Populate the arrays for sorting.while (nodeIterator.MoveNext()){
// Loop until there are no more elementssortArrayWords[arrayPosition] =
nodeIterator.Current.Value;sortArrayKeys[arrayPosition] = arrayPosition;arrayPosition += 1;
}
// Sort the array.Array.Sort(sortArrayWords, sortArrayKeys);arrayPosition = 0;
// Create new XML to update the table.string newTableXML = "";// Iterate through the sorted array of keys.for (int i = 1; i <= sortArrayWords.Length - 1; i++){
nodeIterator = root.Select("/my:ExpenseFields/my:ItemizedExpenses/my:ExpenseRows", this.NamespaceManager);
// Go to the right position in the table.for (int j = 1; j <= sortArrayKeys[i]; j++){
nodeIterator.MoveNext();}
// Add the row to the XML.newTableXML += nodeIterator.Current.OuterXml;
}
// Set the table to use the new XML.root.SelectSingleNode("/my:ExpenseFields/my:ItemizedExpenses", this.NamespaceManager).InnerXml = newTableXML;
Note: The elements in your InfoPath form should match those in the above code.
28 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
17. Hit the F5 button. You will see a preview instance of InfoPath form.
18. Add some rows to the repeating table, with dates in random order as follows:
19. Click the Date button.
20. The rows will be sorted in ascending order.(Note: This code sorts the contents only in ascending order. You can programmatically create a toggle function to sort the contents in ascending and/or descending orders)
29 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
Before Sorting
After Sorting
21. Close the InfoPath preview.
Test and review 22. Save and close the Visual Studio for Application.
23. Publish the InfoPath form as a form template to a forms library. (Follow the instructions in exercise 1)
24. As you did in the exercise 1, test the published form.
30 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Exercise 3: SharePoint data to and from InfoPath Forms.ScenarioIn this exercise you will learn how to display the SharePoint list data in InfoPath forms. You will explore the ability to extend or enhance the forms used by SharePoint lists for creating, editing, or displaying the list items. You will also learn to modify the list forms layouts and to set validation rules using no code. Finally, you will use the one-click publishing capability to publish the forms.
After completing this exercise, you will be able to:
Customize the SharePoint list data entry screen.
Use InfoPath forms to read SharePoint list data.
Use InfoPath forms to write back data to a SharePoint list.
Create simple data validations in the SharePoint list data entry screen.
Task Detailed Steps
Complete these steps by connecting to the computer DEMO2010A.
Create the Categories SharePoint list.
1. Open an Internet Explorer browser window and browse to http://intranet.contoso.com
2. On the Site Actions menu, click More Options.
3. Choose List from the left panel, and then select Custom List.
4. Type Categories as the list name, and click the Create button.
5. Navigate to the Categories list.
6. On the ribbon, click the List Tools and then click List.
7. Click Create Column:
31 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps8. Create a column named Category of type Text.
9. Click List Settings.
10. Click Advanced Settings.
11. Set Allow Management of Content Types to Yes:
12. Click OK.
13. Under Content Types, click Item:
14. Under Columns, click Title.
15. Under Column settings, select Hidden, and then click OK:
16. Navigate back to the Categories list.
17. Click Add a new Item, and add the following items one-by-one:
Auto
Apparel
Electronics
Sports
Create the Products 18. Browse to the root site at http://intranet.contoso.com
32 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed StepsSharePoint list.
19. On the Site Actions menu, click More Options.
20. Choose List from the left panel, and select Custom List.
21. Type Products as the list name, and click the Create button
22. Navigate to the Products List.
23. Click List Settings.
24. Click Advanced Settings.
25. Set Allow Management of Content Types to Yes, and click OK.
26. Under Content Types, click Item.
27. Under Columns, click Title.
28. Under Column settings, select Hidden. Click OK.
29. Create a new column, Product, with the following specifications:
a. Type: Single line of Text.
b. Require that this column contains Information: Yes
c. Maximum number of characters: 50
30. Create a new column, Category, with the following specifications:
a. Type: Lookup (information already on the site)
b. Get Information From: Select Categories
c. In this Column: Select Category
31. Create a new column, Product Price with the following specifications:
a. Type: Currency
b. Require that this column contains Information: Yes
c. Currency Format: US Dollars
32. Navigate to Products list.
33. Click Add a new Item, and add some products in each category as follows:
33 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
Create the Orders SharePoint list.
34. From Site Actions, Click More Options.
35. Choose List from the left panel, and select Custom List.
36. Type Orders as the list name, and click the Create button.
37. Navigate to the Orders List.
38. Click List Settings.
39. Under columns, select Title.
40. Make the Title field not a required field by setting Require that this column contains Information to No.
41. Click Advanced Settings.
42. Set Allow Management of Content Types to Yes, and then click OK.
43. Under Content Types, click Item.
44. Under Columns, click Title.
45. Under Column settings, select Hidden. Click OK.
46. Create a new column, Customer, with the following specifications:
a. Type: Single line of Text
b. Require that this column contains Information: Yes
c. Maximum number of characters: 50
47. Create a new column, Category with the following specifications:
a. Type: Lookup (information already on the site)
b. Get Information From: Select Categories
c. In this Column: Select Category
34 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps48. Create a new column, Product with the following specifications:
a. Type: Lookup (information already on the site)
b. Get Information From: Select Products
c. In this Column: Select Product
49. Create a new column, Order Quantity, with the following specifications:
a. Type: Number
b. Require that this column contains Information: Yes
c. Number of decimal places: 0
50. Create a new column, Order Price, with the following specifications:
a. Type: Currency
b. Require that this column contains Information: Yes
51. Create a new column, Total Price, with the following specifications:
a. Type: Currency
b. Require that this column contains Information: Yes
Design the "New Item" form for the Orders list
In earlier versions of SharePoint, list forms were regular ASP.NET pages making it challenging to add custom business rules to validate the data entered. One such example is the need to filter the items in a drop-down list based on a selected item in another drop-down list.
For example, in this scenario one would like to display the list of products for a
52. Navigate to the Orders List.
53. Click Add a new Item.
54. Type a customer name (Ex: Fabrikam)
55. Select Sports from the Category drop-down list.
56. Click the drop-down list for Products. Ideally, one would expect to see the products that belong to Sports category. However, all products from all categories are displayed in the drop-down list.
35 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Stepsselected category only. With InfoPath this is possible without having to write a single line of code.
In the following steps, you will customize this InfoPath form and add rules to display only the products belonging to the selected category.
57. Click Cancel to close the form without saving the data.
Customize the list data entry InfoPath form
58. Navigate to the Orders list.
59. On the ribbon, click List Tools, and then click List.
60. Click Customize Form:
61. The list data entry InfoPath form will open in design mode.
62. On the Fields Task Pane on the left, click Show advanced view.
63. Click the drop-down list under Fields. You will see that apart from the Main data connection, there are two other connections - Products (Secondary) and Categories (Secondary). These are the data connections to the Products and Categories lists respectively:
64. Select Products, and expand all the elements underneath. You will see that the data connection only retrieves Product Name and ID:
Create Data Connection
65. On the ribbon, select the Data tab.
36 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
In this step, you will create a new data connection to a products list to retrieve products as well as categories. That way, you can match the products to the categories.
66. Click Data Connection, and then click Add.
67. Select Create a new Connection to: and select Receive Data, then click Next.
68. Select SharePoint library or list.
69. Enter the location of your SharePoint site hosting the Orders, Products and Categories tables (http://intranet.contoso.com/). Click Next.
70. From Select a list or library, click Products, and then click Next.
71. Select Product Name, Category and Product Price.
72. Select Sort By: ID.
73. Select Sort Order: Ascending:
Click Next.
74. Click Next.
75. Type Products_New as the name of this data connection. Check the option Automatically retrieve the data when form is opened, and then click Finish.
76. Click Close to close the Data Connections dialog box.
77. Right-click the Product drop-down list
78. For Data Source, Select Product_New. (Here you are changing the existing data connection to the newly created data connection)
79. Click the button ( ) next to Entries field.
80. Click Filter Data.
37 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
Create a filter to show all Products whose respective Category matches the Category that the user selects in the Form
81. In the Filter Data dialog box, click Add. (This is to add a new filter condition)
82. In the first drop-down list, choose Select a field or group.
83. In the Select a field or group dialog box, select Products_New as Data source
84. Expand myFields, and then expand all elements under dataFields.
85. Select Category:
86. Click OK.
87. In the Filter Conditions dialog box, select is equal to as follows:
88. Select the third drop-down list, and click Select a field or group
89. Select Main from the drop-down list.
90. Expand myFields, and then expand all elements under dataFields.
91. Select Category:
38 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
Click OK.
92. Click OK on all the dialog boxes till you are back to the drop-down list Properties dialog box.
93. Click the button ( ) next to Value field, and then select ID.
94. Click the button ( ) next to Display name field, and then select Product Name.
95. Click OK.
Preview & test the data filtering.
96. Click the Preview button. The InfoPath form will open in preview mode.
39 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
97. Select a Category (Ex: Sports). Now click the drop-down list for Products. You will see only the products that match the selected category.
98. Close the form preview.
99. On the ribbon, select Home tab.
100. Select the Category drop-down list.
101. Click Manage Rules. The Rules pane will be displayed on the right.
102. Click New and select Action:
40 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
103. Type Clear Product List as the name for this rule and press the TAB key.
104. Leave the Rule Type as Action:
105. Click the Add button next to Run these actions* label
106. Select Set a field's value:
41 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
107. In The Rule Details dialog box, Click the button ( ) next to Field.
108. Select Product from the list:
Click OK.
109. Leave the Value blank (By setting the Product field to blank, we are clearing the product list before the list is re-populated again), and then click OK.
Fetch the pricing information
In this step, you are fetching the price of the selected product from the Products list. Price of products can change frequently. For orders management, you need to capture
110. In the InfoPath designer, right-click Order Price field.
111. Click Text Box Properties.
112. Click the Display tab.
113. Check Read-Only:(The price cannot be changed by the user filling out the form. The price is for display only)
42 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Stepsthe correct price when the order was placed.
114. Click the Data tab.
115. Click the (fx) button
116. Click Insert Field or Group…
117. Click Show Advanced View.
118. Select Products_New (Secondary) from the drop-down list.
119. Expand all elements under myFields.
120. Under dataFields, select Product Price.
121. Click Filter Data.
122. Click Add.
123. In the first drop-down list, set the following:
a. Select the Select a field or group
b. From the Data source list , select Products_New (Secondary), and select ID:
c. Click OK.
124. In the Specify Filter Conditions dialog box, set the operator (second drop-
43 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Stepsdown list) to is equal to
125. In the third drop-down list, select Select a field or group
126. Choose Main, and expand all elements. Under dataFields, select Product.
127. Click OK. The filter condition should look as follows:
128. Click OK on all open dialog boxes.
Publish the form 129. On the ribbon, select File tab, and then click Quick Publish.
130. Wait for the form to be published.
Test 131. Navigate to the Orders List, and click Add a new Item.
132. Add a new item and save the form. You will notice that the Products drop-down list display products matching the selected category. Also, the current price of the product is fetched from the Products list.
44 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
133. Save the form as you did in the earlier exercises.
45 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Exercise 4: InfoPath Forms to Read and Write to Line of Business (LOB) SystemsScenarioThis lab provides you with a basic understanding of using InfoPath 2010 in conjunction with SharePoint 2010 to read and write information via SharePoint 2010 from Line of Business applications. You will learn how to use InfoPath 2010, trusted Data Connection libraries in SharePoint 2010, and Web services to read from a SQL Server 2008 data source. You will also learn at a very high level how to write data back to the line of business systems
After completing this exercise, you will be able to:
Create and use data connection libraries.
Create and use universal data connection files.
Create data connections to SQL Server from InfoPath forms.
Retrieve and display data from databases in InfoPath forms..
Task Detailed Steps
Complete these steps by connecting to the computer DEMO2010A.
Create a Data Connections library
The Data Connection Library (DCL) is a kind of document library in Microsoft SharePoint Server 2010 that enables applications such as Microsoft InfoPath 2010 and technologies such as Excel Services to specify data connection settings using external files.
1. Open a Internet Explorer browser window, and browse to http://intranet.contoso.com/
2. On the Site Actions menu, select All Site Content, and then click Create.
3. From the available template categories, select Library.
4. Select the Data Connection Library template to a new Data connection library. Type DataConnections as the name of the library.
5. Click the Create button.
Create a new InfoPath form and add a Data Connection to read data from SQL
6. Click Start | All Programs | Microsoft Office | Microsoft InfoPath Designer
2010 Designer menu.
7. Follow the instructions in the Lab 1 (Forms for Process Management) and
46 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed StepsDatabase create a new Blank Form.
8. On the ribbon, click the Data tab, and then click Data Connections.
9. In the Data Connections dialog box, click Add.
10. Select Create a new connection to: and select Receive data, and then click
Next.
11. Select the option Database (Microsoft SQL Server only), and then click Next.
12. Click the Select Database button.
13. In the Select Data Source dialog box, click New Source.
14. In the Data Connection Wizard dialog box, select Microsoft SQL Server. Click
Next.
15. Type DEMO2010A as the Server Name. Select Use Windows Authentication:
16. Click Next.
Use Adventure Works Database
17. Select the AdventureWorksDW option from the Select the database that
contains the data you want drop-down list.
18. Unselect the Connect to a specific table option and click the Next button:
47 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
19. In the Save Data Connection File and Finish section, accept the default values,
and click Finish:
20. Select the DimProduct table, and click the OK button.
48 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
21. In the next screen, all the columns from the DimProduct table will be selected
by default. Accept the default selections, and click Next.
22. Click Next.
23. Type DimProduct as the name of Data Connection. Leave the Automatically
retrieve data when form is opened option checked.
24. Click Finish.
Create a data connection file (.udcx)
A data connection file is an XML file that contains connection information for a single external data source and has an .xml or .udcx file name extension. When a user opens a form that connects to a data connection file, InfoPath uses the settings in that file to connect to the external data source
25. In the Data Connections dialog box, click Convert to Connection File.
26. Save this data connection to the data connection library that you created
earlier. Type SQLDC.udcx as the name of the file.
(http://intranet.contoso.com/DataConnections/SQLDC.udcx).
27. Click the OK button.
28. Click the Close in the Data Connections window.
29. Open an Internet Explorer browser window, and browse to the Data
Connections library.
(http://intranet.contoso.com/dataconnections).
30. Choose Approve/Reject from the drop-down menu for the SQLDC.udcx data
connection:
49 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
31. Select Approved, and click the OK button.
Design the InfoPath form
32. Return to the InfoPath Designer.
33. On the ribbon, click the Home tab.
34. From the controls section, select Repeating Table:
35. Change the Number of columns to 4 in the Insert Repeating Table dialog. A
Repeating table with 4 columns has been added to your form.
36. Right-click anywhere inside the top row of the inserted table, and click Change
Binding:
50 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps
37. In the Repeating Table Binding dialog box, select DimProduct (Secondary) as
the Data Source.
38. Expand the dataFields node in the Specify which group to bind the rows to
section.
39. Select d:DimProduct, and click the Next button:
40. Select the following columns from the Data binding section, and click the
Add>> button to move them to the Columns in table :
a. ProductKey
b. ProductAlternateKey
51 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed Stepsc. EnglishProductName
d. ReorderPoint
41. Click the Finish button:
42. Right-click the Product Key text box and select the Text Box Properties option:
43. Click the Display tab.
44. Select the Read only option.
45. Click OK.
52 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Task Detailed Steps46. Click the repeating table to select it.
47. On the ribbon, click the Home tab.
48. Click Manage Rules.
49. In the Rules pane, click New and then select Formatting.
50. In the Details for section, under Condition, click None.
51. Change the is equal to drop-down list item to is greater than.
52. Change the third drop-down to Type a number:
53. Enter 100 as the value. Click OK.
54. In the Rules pane, check Hide this control.
Form Options 55. On the ribbon, click the File tab, and then click Form Options.
56. Select Security and Trust.
57. De-select the Automatically determine security level option.
58. In the Security Level section, select Full Trust:
59. Click the OK button.
60. Click the Preview button to verify that the form and data connection are
working properly.
Publish the Form 61. Follow the instructions in Exercise 1 to publish the form as a form template to a
SharePoint library. Test the InfoPath form.
Write data back to Writing data back to SQL (or any other LOB system) requires a little more effort.
53 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
Task Detailed StepsSQL Database This is again achieved via a Web service with Write capabilities to the SQL
Database. At this time, there is no out-of-the-box Web service that is available to
write back data to a database. A custom Web service is required, and using the
Web service, the user can create a Data Connection to submit data to a Web
service. (Submitting data via data connection has been explained in Exercise 3:
SharePoint Data to and from InfoPath Forms).
You can also use Business Data Connectivity Services (BCS) to create a direct
connection to a SQL database. "Write" capabilities can be included in the
connection. You can customize the data entry screen of the resulting External list.
You will learn more about BCS in Module 5 of this series.
You have now completed this lab.
54 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
Appendix
Labcode Manual Version Last UpdateVersion 7 12/8/2010 6:38:00 PM
Lab Notes
Description Details
Virtual Machine Requirements
Virtual Machine Name Details
Adventureworks Database Installation Instructions
1. The AdventureWorks sample database installer is located on the DEMO2010A Virtual machine at C:\AdventureWorksDB\AdventureWorks2008R2_RTM.exe
2. Click the AdventureWorks2008R2_RTM.exe
3. Allow the installation files to be extracted.
55 Microsoft Confidential - For Internal Use Only
InfoPath Forms Services 2010- Appendix
4. Click, I accept the license terms and then click Next.
5. Select DEMO2010A as the Installation Instance, and then click Install.
6. Wait for the installation to complete
56 © 2023 Microsoft Corporation. All rights reserved.
InfoPath Forms Services 2010- Appendix
7. Click the Finish button
57 Microsoft Confidential - For Internal Use Only