Tuesday, September 29, 2009

FAQ on InfoPath 2007

What are browser-compatible forms?

InfoPath 2007 introduced the possibility to fill out InfoPath forms by using a browser such as Internet Explorer, Firefox, Netscape, or Safari. These types of forms are called InfoPath 2007 browser-compatible forms. For a complete list of browsers that can be used to fill out InfoPath form.

Can I use browser-compatible forms without installing Microsoft Office SharePoint Server 2007 (MOSS)?

Yes, you can, but you will have to install Forms Server to be able to run browser-compatible forms.

What is Forms Server?
Forms Server is the extracted version of Forms Services that comes with Microsoft Office SharePoint Server 2007 (MOSS). It is sold and can be used separately from MOSS to run and fill out InfoPath 2007 browser-compatible forms.

How do I make InfoPath 2007 forms compatible with InfoPath 2003?

Open the form template that you want to save in InfoPath 2003 format.
On the File menu, click Save As.
In the Save as type list, click InfoPath 2003 Form Template.
Click Save.

How do I retrieve the value of an InfoPath field through code?

In C# code:
XPathNavigator nav = MainDataSource.CreateNavigator();
string fieldValue = nav.SelectSingleNode("//my:field1", NamespaceManager).Value;

In VB.NET code:
Dim nav As XPathNavigator = MainDataSource.CreateNavigator()
Dim fieldValue As String = nav.SelectSingleNode("//my:field1", NamespaceManager).Value
How do I set the value of an InfoPath field through code?

In C# code:
XPathNavigator nav = MainDataSource.CreateNavigator();
nav.SelectSingleNode("//my:field1", NamespaceManager).SetValue("myValue");

In VB.NET code:
Dim nav As XPathNavigator = MainDataSource.CreateNavigator()
nav.SelectSingleNode("//my:field1", NamespaceManager).SetValue("myValue")

How do I call a web service through code?
In C# code:
// Create an XPathNavigator object to navigate the data source of the web service
XPathNavigator nav = DataSources["HelloWorld"].CreateNavigator();

// Set the value of the parameter to pass to the web service
nav.SelectSingleNode("//dfs:queryFields/tns:HelloWorld/tns:name", NamespaceManager).SetValue("myValue");

// Call the web service
DataSources["HelloWorld"].QueryConnection.Execute();

// Retrieve the results returned by the web service
string results = nav.SelectSingleNode("//dfs:dataFields/tns:HelloWorldResponse/tns:HelloWorldResult", NamespaceManager).Value;


where HelloWorld is the name of a data connection to a web service.

In VB.NET code:
' Create an XPathNavigator object to navigate the data source of the web service
Dim nav As XPathNavigator = DataSources("HelloWorld").CreateNavigator()

' Set the value of the parameter to pass to the web service
nav.SelectSingleNode("//dfs:queryFields/tns:HelloWorld/tns:name", NamespaceManager).SetValue("myValue")

' Call the web service
DataSources("HelloWorld").QueryConnection.Execute()

' Retrieve the results returned by the web service
Dim results As String = nav.SelectSingleNode("//dfs:dataFields/tns:HelloWorldResponse/tns:HelloWorldResult", NamespaceManager).Value

Where HelloWorld is the name of a data connection to a web service.

Date and time basics in Microsoft Office InfoPath

Problem
you want to filter data on the current month, display the date in a way that is not available in Microsoft Office InfoPath, or perform calculations with dates.

Solution
Use the fact that Microsoft Office InfoPath represents dates and times internally as YYYY-MM-DDThh:mm:ss to be able to filter, display, and perform calculations with dates and times within InfoPath.

Discussion
InfoPath comes with 3 date/time data types:
1. Date (date)
2. Time (time)
3. Date and Time (dateTime)
The following table lists the corresponding internal representations InfoPath uses for each data type:


Data Type Internal InfoPath Representation

Date (date) YYYY-MM-DD

Time (time) hh:mm:ss

Date and Time (dateTime) YYYY-MM-DDThh:mm:ss

InfoPath uses the format you set on a date/time field through the Properties dialog box of the field and the Format... button to display dates and times. InfoPath will show dates/times in any way you have indicated, like e.g. 9:46 P.M., 21:46, 2/19/2006, or 19-02-2006. Keep in mind that this is only a visual display. When InfoPath performs validation on date and time fields, it still uses its own internal date and time representations.

This is important to know when you want to write date and time values to fields using code. If for example you set a field's data type to Date (date) and you write 2006-02-19T13:00:23 to the field through code, you will get the following validation error:

To correct this error, change the field's data type to Date (date) and write 2006-02-19 to the field, or change the field's data type to Date and Time (dateTime) and write 2006-02-19T13:00:23 to the field.

0 comments: