Infopath Forms Services 2010
Total Page:16
File Type:pdf, Size:1020Kb
InfoPath Forms Services 2010
Hands-on Lab Terms of Use
This 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 © 2018 Microsoft Corporation. All rights reserved. About the Author Author: Ravi Vridhagiri Bio: 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
4 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
Lab Environment During 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 DEMO2010A This 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 Password Administrator 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.
5 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
Lab Overview Abstract
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
6 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
Exercise 1: InfoPath Forms for Process Management Scenario In 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 1. Click Start | All Programs | Microsoft Office | Microsoft Form InfoPath Designer 2010 Designer menu.
7 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
2. On the File tab, click New.
3. Under Available Form Templates, select Blank Form.
4. Click Design Form.
8 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
5. On the Insert tab on the ribbon, click Custom Table, and then click Layout table.
6. In the Insert Table dialog box, set the following:
Number of columns: 2
Number of rows: 2
9 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
7. Click OK.
Design the Form by 8. On the ribbon, click the Home tab. adding controls 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.
11. Add the Employee Name field as follows:
a. On the Controls toolbar, click Text Box to add a Text Box control
10 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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.
11 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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.
12 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
13 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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.
14 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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:
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:
16 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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).
17 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
21. Click OK.
22. Similarly add additional items for ExpenseCategory as follows:
18 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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:
19 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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 26. Right-click the ExpenseTotal field. the itemized expenses 27. Click Text Box Properties.
28. Click the fx button next to Value:
29. Click the Insert Function button:
20 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
30. From the list of Categories, select Math.
31. From the list of Functions, select Sum:
32. Click OK.
33. Back in the Insert Formula dialog box, double-click double click to
21 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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 36. Right-click on the EmployeeName Text Box and click Text Box the employee filling Properties out the form
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:
22 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
41. Click OK on all open dialog boxes to complete this step.
NOTE: The steps 42 to 47 are Optional
Add additional 42. The Employee Name field should be a read-only field. To make it formatting and read only, right-click the EmployeeName text box and click Text Box validation Properties.
43. On the Display tab, select Read-only, and then click OK:
23 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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:
24 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
Create a new forms 48. Open an Internet Explorer browser window and browse to library where the http://intranet.contoso.com/. forms can be 49. On the Site Actions menu, click More Options. submitted to
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:
25 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
55. Right-click the button and click Button Properties.
56. Change the text to Submit.
57. Click OK.
26 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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
27 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
(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:
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 76. On the Ribbon, click the File tab. InfoPath form fields 77. Select Info. as SharePoint metadata 78. Click Advanced Form Options.
79. In the Form Options dialog box, choose Property Promotion. Property promotion enables SharePoint 80. Click Add. to extract and store 81. Select EmployeeName, ExpenseTotal, ExpensePeriodFrom and
28 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix the values of the ExpensePeriodTo to the list of properties to be promoted. 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.
82. Click OK.
Publish the form as a 83. On the ribbon, click the File tab. form template 84. Click Publish.
85. Click SharePoint Server. There are three ways a form can be 86. Type the location of the SharePoint site (Ex: published: as a form http://intranet.contoso.com/) template for a library, as a Content 87. Select Enable this form to be filled out by using a browser, and Type, and as an select Form Library, and then click Next: administrator- approved form.
29 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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 93. Open a Internet Explorer browser window and browse to deployed form 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 96. Go back to the ExpenseReimbusement.xsn form in InfoPath Content Type designer
97. Delete the Submit button. (Select the Submit button, and press A site content type DELETE) allows a form to be 98. On the File tab, click Info, and then click Advanced form Options. used in multiple libraries and sites. 99. Select Web Browser under the list of Categories. Publishing an InfoPath form as a 100. Make sure the Show InfoPath Commands in Ribbon or toolbar content type is checked. enables the form to 101. Under Show the following commands:, uncheck all options be used throughout except Save and Close. the site collection.
30 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
102. Click OK.
103. Click the save icon to save the form:
Publish the form as a 104. On the ribbon, click the File tab. Content type. 105. Click Publish.
106. Click SharePoint Server:
107. Type http://intranet.contoso.com/ as the location of the
31 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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:
109. Select Create a new Content Type, and then click Next:
32 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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 114. Open an Internet Explorer browser window and navigate to using the form http://intranet.contoso.com Content Type
115. 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)
33 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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
34 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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. Note: You will only be able to save this to the parent forms library
NOTE: The steps 130 to 146 are Optional
Add workflow 130. Navigate to the forms library that you created in the earlier capabilities to the tasks. form library (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:
35 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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.
36 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
139. Click Save to finish configuring the workflow. Review and test the 140. Navigate to the Expense Reports New forms library. process. 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 see that a task has been assigned to a Contoso user seeking approval for the submitted expense report.
37 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
Exercise 2: Forms as Sandboxed Solution Scenario Sandboxed 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 1. Right-click the ExpenseReimbursement.xsn , and click Design Programming language. 2. On the ribbon, click the File tab, and then click Info. 3. In the Advanced Form options section, click Form Options.
The programming languages that are supported for the form template are either C# or Visual Basic. This requires that Visual Studio 4. In the Form Options dialog box, from the list of available Tools for categories, select Programming. Applications (VSTA) be installed and .Net 5. Select C# as the Form template code language Programming support for InfoPath be enabled.
6. Click the Browse button and choose a project location where you
38 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
would like to store the project:
7. Click OK.
Add managed Code to 8. On the ribbon, click the Home tab. the InfoPath form 9. From the Controls select Button, and add a new button control to the form.
The repeating control 10. Move the button to the Date header column of the repeating that we added in the table. Expense Report form does not have sorting 11. Right-click the button and then click Button Properties. capability. When the form is submitted for 12. Change the label to Date. Click OK. review/approval, the ability to sort the submitted expense by date, amount or by category is a “nice to have”. This code sorts 13. Right-click the button again, and then click Button Properties. the rows based on the Expense Date column 14. Under Action, select Rules and Custom Code. in the table, but you 15. Click Edit Form Code. This will launch Microsoft Visual Studio for can easily modify the Applications. code to work with any column. 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",
39 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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:Exp enseDate", this.NamespaceManager);
// Create arrays to use for sorting. string[] sortArrayWords = new string[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 elements sortArrayWords[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:Expens eRows", this.NamespaceManager);
40 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
// 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.
41 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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)
42 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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.
43 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
Exercise 3: SharePoint data to and from InfoPath Forms. Scenario In 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 1. Open an Internet Explorer browser window and browse to SharePoint list. 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:
44 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
8. 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:
45 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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 SharePoint 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.
46 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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:
Create the Orders 34. From Site Actions, Click More Options. SharePoint list. 35. Choose List from the left panel, and select Custom List.
47 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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
48. 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:
48 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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 52. Navigate to the Orders List. Item" form for the Orders list 53. Click Add a new Item.
54. Type a customer name (Ex: Fabrikam)
In earlier versions of 55. Select Sports from the Category drop-down list. SharePoint, list forms were regular ASP.NET 56. Click the drop-down list for Products. pages making it Ideally, one would expect to see the products that belong to Sports challenging to add category. However, all products from all categories are displayed in the custom business rules drop-down list. 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 selected category
49 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix only. With InfoPath In the following steps, you will customize this InfoPath form and add rules this is possible to display only the products belonging to the selected category. without having to write a single line of 57. Click Cancel to close the form without saving the data. code.
Customize the list 58. Navigate to the Orders list. data entry InfoPath form 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:
50 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
Create Data 65. On the ribbon, select the Data tab. Connection 66. Click Data Connection, and then click Add.
67. Select Create a new Connection to: and select Receive Data, then click Next.
In this step, you will 68. Select SharePoint library or list. create a new data connection to a 69. Enter the location of your SharePoint site hosting the Orders, products list to Products and Categories tables (http://intranet.contoso.com/). Click Next. retrieve products as well as categories. 70. From Select a list or library, click Products, and then click Next. That way, you can 71. Select Product Name, Category and Product Price. match the products to the categories. 72. Select Sort By: ID.
73. Select Sort Order: Ascending:
51 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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.
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. Create a filter to show all Products whose 83. In the Select a field or group dialog box, select Products_New as respective Category Data source matches the Category that the user selects in 84. Expand myFields, and then expand all elements under dataFields. the Form 85. Select Category:
52 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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:
53 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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 96. Click the Preview button. The InfoPath form will open in preview data filtering.
54 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
mode.
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:
55 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
103. Type Clear Product List as the name for this rule and press the TAB key.
104. Leave the Rule Type as Action:
56 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
105. Click the Add button next to Run these actions* label
106. Select Set a field's value:
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 110. In the InfoPath designer, right-click Order Price field. information
57 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
111. Click Text Box Properties.
112. Click the Display tab.
In this step, you are 113. Check Read-Only: fetching the price of (The price cannot be changed by the user filling out the form. The price is the selected product for display only) from the Products list. Price of products can change frequently. For orders management, you need to capture the 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:
58 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
c. Click OK.
124. In the Specify Filter Conditions dialog box, set the operator (second drop-down 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.
59 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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.
133. Save the form as you did in the earlier exercises.
60 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
61 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
Exercise 4: InfoPath Forms to Read and Write to Line of Business (LOB) Systems Scenario This 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 1. Open a Internet Explorer browser window, and browse to Connections library http://intranet.contoso.com/
The Data Connection 2. On the Site Actions menu, select All Site Content, and then click Create. Library (DCL) is a kind 3. From the available template categories, select Library. of document library in Microsoft SharePoint 4. Select the Data Connection Library template to a new Data connection library. Server 2010 that Type DataConnections as the name of the library. enables applications 5. Click the Create button. such as Microsoft InfoPath 2010 and technologies such as Excel Services to specify data connection settings using external files.
Create a new InfoPath 6. Click Start | All Programs | Microsoft Office | Microsoft InfoPath Designer
62 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix form and add a Data 2010 Designer menu. Connection to read 7. Follow the instructions in the Lab 1 (Forms for Process Management) and data from SQL create a new Blank Form. Database 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 17. Select the AdventureWorksDW option from the Select the database that Database contains the data you want drop-down list. 18. Unselect the Connect to a specific table option and click the Next button:
63 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
19. In the Save Data Connection File and Finish section, accept the default values, and click Finish:
64 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
20. Select the DimProduct table, and click the OK button.
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
65 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
Automatically retrieve data when form is opened option checked.
24. Click Finish.
Create a data 25. In the Data Connections dialog box, click Convert to Connection connection file (.udcx) File.
A data connection file 26. Save this data connection to the data connection library that you is an XML file that contains connection created earlier. Type SQLDC.udcx as the name of the file. information for a (http://intranet.contoso.com/DataConnections/SQLDC.udcx). single external data source and has an 27. Click the OK button. .xml or .udcx file name extension. When a 28. Click the Close in the Data Connections window. user opens a form that connects to a 29. Open an Internet Explorer browser window, and browse to the data connection file, InfoPath uses the Data Connections library. settings in that file to (http://intranet.contoso.com/dataconnections). connect to the external data source 30. Choose Approve/Reject from the drop-down menu for the SQLDC.udcx data connection:
31. Select Approved, and click the OK button.
Design the InfoPath 32. Return to the InfoPath Designer. form 33. On the ribbon, click the Home tab.
34. From the controls section, select Repeating Table:
66 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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:
67 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
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:
68 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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 c. EnglishProductName d. ReorderPoint 41. Click the Finish button:
42. Right-click the Product Key text box and select the Text Box Properties option:
69 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
43. Click the Display tab. 44. Select the Read only option. 45. Click OK. 46. 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.
70 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
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. SQL 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.
71 Microsoft Confidential - For Internal Use Only InfoPath Forms Services 2010- Appendix
72 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
Appendix
Labcode Manual Version Last Update Version 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.
73 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.
74 © 2018 Microsoft Corporation. All rights reserved. InfoPath Forms Services 2010- Appendix
6. Wait for the installation to complete
7. Click the Finish button
75 Microsoft Confidential - For Internal Use Only