To work around this behavior, use one of the following methods.
Method 1
Create a custom Web service that uses the Windows SharePoint Services object model to read data from the SharePoint list. Then, return the data to an InfoPath form. To do this, follow these steps.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
Step 1: Create a custom Web service
The following example is sample code that creates a custom Web service that returns all fields of all items in a SharePoint list. You can modify the sample code to return only specific fields.
/**********************************************
* *
* *
* *
**********************************************/
[WebMethod]
public XmlDocument MultiLineList()
{
return GetListData("http://ServerName", "List Name ");
}
[WebMethod]
public XmlDocument GetListData(String ServerName, String ListName)
{
String str;
SPList oSPList;
XmlNode oXmlNode;
XmlElement oXmlElement, oXmlParent;
XmlDocument oXmlDocument = new XmlDocument();
oXmlDocument.LoadXml("<SPListItems/>");
using(SPSite oSPSite = new SPSite(ServerName))
{
using(SPWeb oSPWeb = oSPSite.OpenWeb())
{
oSPList = GetList(oSPWeb, ListName);
if(oSPList != null)
{
foreach(SPListItem oSPListItem in oSPList.Items)
{
oXmlParent = oXmlDocument.CreateElement("SPListItem");
oXmlNode = oXmlDocument.DocumentElement.AppendChild(oXmlParent);
foreach(SPField oSPField in oSPListItem.Fields)
{
if(oSPField.Hidden)
continue;
str = oSPField.InternalName.Replace(" ", "");
oXmlElement = oXmlDocument.CreateElement(str);
oXmlParent.AppendChild(oXmlElement);
try
{
str = oSPField.Title;
str = oSPListItem[str].ToString();
}
catch(Exception e)
{
str = "Field error: " + e.Message;
}
oXmlElement.InnerText = str;
}
}
}
}
}
return oXmlDocument;
}
/**********************************************
* *
* *
* *
**********************************************/
private SPList GetList(SPWeb oSPWeb, String strListName)
{
SPList oRet = null;
strListName = strListName.Replace("%20", " ");
strListName = strListName.ToUpper();
foreach(SPList oSPList in oSPWeb.Lists)
{
if(oSPList.Title.ToUpper() == strListName)
{
oRet = oSPList;
break;
}
}
return oRet;
}
Step 2: Create an InfoPath 2003 form to display the data
- Start InfoPath 2003, and then open a new blank form.
- Add a repeating table to the form. To do this, click Repeating Table on the Insert menu.
Note Make sure that the number of fields in the table matches the number of fields in the SharePoint list. - Add a data source to the form. To do this, follow these steps:
- On the Tools menu, click Data Connections, and then click Add.
- Click Receive data, and then click Next.
- Under From where do you want to receive your data, click Web service, and then click Next.
- Type the location of the custom Web service that you created, and then click Next. For example, type the following string:
http://ServerName:8080/Service1.asmx?WSDL
- Click the name of the custom Web service, and then click Finish.
- Bind every field in the table to a field that is returned by the custom Web service. To do this, follow these steps:
- At the bottom of the table, right-click Repeating Table, and then click Change Binding.
- Bind the whole table to the data set. This action creates a link to the data source.
- Right-click the field that will contain the multiline text, and then click Change Binding.
- In the Data source box, click Main, click any other field, and then click OK.
- Right-click the field that will contain the multiline text, click Text Box Properties, and then click the Display tab.
- Click to select the Paragraph breaks check box, and then click OK.
Note If the Paragraph breaks check box is not selected the first time that you follow this step, repeat this step until the Paragraph breaks check box is selected. - Right-click the field of the table that will contain the multiline text again, and then click Change Binding.
- In the Data source box, click Web service, and then click the field.
- Click Preview to preview the form.
Method 2
Export the data from the SharePoint list to an Excel 2003 workbook. After you export the data to an Excel 2003 workbook, you can use scripts, macros, or other applications to retrieve and then display the data.
To do this, follow these steps.
Step 1: Export the data from the SharePoint list to an Excel 2003 workbook
- In a Web browser, connect to the list on the SharePoint site.
- Under Actions, click Export to spreadsheet, and then click OK in the File Download dialog box.
- In the Opening Query dialog box, click Open.
- In the Import Data dialog box, specify where you want to put the data, and then click OK.
Step 2: Use macros, scripts, or other applications to retrieve and then display the data
To use the mail merge feature in Microsoft Office Word 2003 to display the data, follow these steps:
- Start Word 2003, and then open a new blank document.
- On the Tools menu, point to Letters and Mailings, and then click Mail Merge.
- Under Select document type in the Mail Merge pane, click Letters, and then click Next: Starting document.
- Under Select starting document, click Use the current document, and then click Next: Select recipients.
- Under Select recipients, click Use an existing list, and then click Next: Write your letter.
- In the Select Data Source dialog box, locate and then click the Excel 2003 workbook that contains the exported data, and then click Open.
- Specify the records that you want to display, click OK, and then click Next: Write your letter.
- Under Write your letter, add the items that you want to use in the document, and then click Next: Preview your letters.
- Preview the letter, and then click Next: Complete the merge.
- Under Next: Complete the merge, click Edit individual letters to display all items in one document
Method 3
In Excel 2003, create a data source to retrieve data from the SharePoint list. After you do this, you can use scripts, macros, or other applications to retrieve and then display the data.
To do this, follow these steps.
Step 1: Create a data source in Excel 2003 to retrieve the data from the SharePoint list
- Start Excel 2003, and then open a new workbook.
- On the Data menu, point to XML, and then click XML Source.
- In the XML Source pane, click XML Maps, and then click Add.
- Take one of the following actions:
- Click New Source. The Data Connection wizard starts. Go to step 1e, and then follow the remaining steps in this procedure.
- Click an existing XML source, click Open, and then click OK. You do not have to follow the remaining steps in this procedure.
- Under What kind of data source do you want to connect to in the Data Connection wizard, click Windows SharePoint Services lists, and then click Next.
- Type the URL of the SharePoint site that contains the list, and then click Next.
- Under Select the object that contains the data you want, click the name of the list, and then click Next.
- Specify the fields that you want to display, and then click Next.
- If you want to sort the data, specify the sort criteria that you want, and then click Next.
- If you want to filter data, specify the filter criteria that you want, and then click Next.
- If you want to limit the number of rows that are retrieved, specify the number of rows that you want, and then click Next.
- Type a name for the data source, and then click Finish.
- Click Open, and then click OK.
Step 2: Use macros, scripts, or other applications to retrieve and display the data
For example, you can use the mail merge feature in Word 2003 to display the information. For more information about how to do this, see the "Step 2: Use macros, scripts or other applications to retrieve and display the data" subsection of the "Method 2" section earlier in this article.