Thursday, 7 August 2008

XmlFormView used in a Sharepoint Environment Error

When following the tutorial on deploying an infopath form in web page into sharepoint you might get the strangest of errors saying

"The type 'Microsoft.Office.InfoPath.XmlForm' is defined in an assembly that is not referenced."

If you get this ensure that the web.config file for the SharePoint contains the Infopath Assemblies

-----web.config ----


This is the url that walks thru the hosting of the infopath forms in a custom page. Please be aware that the tutorial only caters for situations where you are hosting the .net page in the root site collection.

Using query string with InfoPath forms

Sometimes it is necessary to accept query string for browser enabled info path forms. This can be done by hosting the Infopath form in a page and hosting that page within Sharepoint using the XmlFormView class.

This technical guide explains the process

The code behind for the page will contain a method like the one shown below..

protected void XmlFormView1_Initialize(object sender, InitializeEventArgs e)
string positionAppliedFor = Request.QueryString["Position"];
string jobID = Request.QueryString["JobID"];
string appURL = Request.QueryString["AppURL"];

if (!string.IsNullOrEmpty(positionAppliedFor) && (!string.IsNullOrEmpty(jobID)))
// Create an XPathNavigator positioned at the root of
// the form's main data source.
XPathNavigator xNavMain = XmlFormView1.XmlForm.MainDataSource.CreateNavigator();
// Create an XmlNamespaceManager and add the "my" namespace
// alias from the form's main data source.
XmlNamespaceManager xNameSpace = new XmlNamespaceManager(new NameTable());
xNameSpace.AddNamespace("my", "");
// Create an XPathNavigator positioned on the form's field2.
XPathNavigator fTextBoxPosition = xNavMain.SelectSingleNode(
"/my:myFields/my:gpRecommendation/my:txtPositionAppliedFor", xNameSpace);
// Set the form's job Position Value to the value passed in the query strings

XPathNavigator fTextBoxJobID = xNavMain.SelectSingleNode(
"/my:myFields/my:gpRecommendation/my:txtJobID", xNameSpace);

if (!string.IsNullOrEmpty(appURL))
XPathNavigator fTextBoxAppURL = xNavMain.SelectSingleNode(
"/my:myFields/my:gpRecommendation/my:txtAppURL", xNameSpace);

Installing SharePoint on a simple farm

Very comprehensive guide on installing SharePoint on a simple farm

Validating Currency fields regular expression

Expression: ^\d{0,2}($|\.\d{0,2}$)
Example of valid values:

Example of invalid values: