Tuesday, June 27, 2006

Passing query string to a Infopath 2007 form

Support of infopath 2007 browser rendering has opened a whole lot of options for web forms. Now instead of creating a form in ASPX , one can create an infopath form and take advantage of various submitting options like submitting to web service, database etc.

One feature which I find hard to get is passing parameters to infopath form so that it can dynamically present the data to user. For Ex you can pass a customer id to the infopath form which updates the database based on that customer ID.

Normally rendering the infopath form using document library prevents us to pass our own parameters throught the URL since the URL is automatically generated by the Forms Server.

The trick is to use XMLFormView control as described in this link

Observe the code in OnInitialize event, here you can grap the parameter in the query string and send it to your infopath form to a text box. That text box can be set to hidden if possible.
protected void _xmlFormView1_OnInitialize(object sender, EventArgs e)
XPathNavigator xNavMain = XmlFormView1.XmlForm.MainDataSource.CreateNavigator();
XmlNamespaceManager xNameSpace = new XmlNamespaceManager(new NameTable());
xNameSpace.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-04-20T16:26:21");
XPathNavigator fTextBox1 = xNavMain.SelectSingleNode("my:myFields/my:field2", xNameSpace);

This way you can pass the dynamic parameters to the infopath form rendered in the browser.
Note that the namespace specified here must be exactly same as that specified in your form.
To find out your namespace, rename the .xsn file to .cab and open the template.xml file.

Happy Working :)

kick it on SharePointKicks.com

Monday, June 26, 2006

Installing MOSS 2007 on a single standalone machine

Normal installation of MOSS 2007 require a farm of computers like domain controller, database server and atlast a web server for a reasonable performance. But if you are a home user like me, who has unfortunately only a single laptop , even then you can install MOSS 2007 on your PC without installing Active Directory and that too with good performance.

The key to installing on a single machine is not choosing the standalone option while installing MOSS 2007. The standalone option works fine when installed with a domain account but on a standalone machine it fails on Step 8 with SQLException of failed login.

To Install MOSS 2007 on a single machine follow these steps:
  • Do a clean installation of Windows Server 2003
  • Install SP1
  • Configure the server as Application server with ASP.net support.
  • Install .net 2.0 framework
  • Install Windows Workflow components beta 2
  • Install either SQL 2k5, 2k or SQL Express
  • Install MOSS 2007 and choose complete option.
When it asks for the database server in the configuration wizard, give the name of your own machine as the database server. This is installing farm configuration but on the single machine.This way you dont even need the domain controller or a domain account.

Saturday, June 24, 2006

Limitations of Infopath 2007

Ability to submit to SQL Server

o In order to submit to a database (Access or SQL Server) you need to initially create the InfoPath form from the Access or SQL Database. So if you, say, created a “blank” form, added nodes, controls, etcAndnd now want to submit that to SQL Server there is no way to reverse engineer that template to do so.

o Assuming you did initially create the InfoPath form directly on your SQL Server database, you will not be able to “submit” to that database if your form was designed for both the client and the web browser. If this is the case, it is by design that you cannot submit directly to a database from a web enabled form.

- Message about an Administrator needing to approve the template

o This is also by design. If you create a form that includes the ability to be displayed in the web browser *and* either include managed code and/or set the form to Full Trust, you cannot deploy that form directly to Office Server. This is a security decision that was made: if your form requires Full Trust or contains managed code then a server administrator needs to be aware of this – hence the only way to get this form deployed is via an “Admin” deployment.

Friday, June 23, 2006

Publishing Infopath 2007 documents in Browser

Infopath 2007 brings the new feature of rendering the infopath documents in the browser. However this feature can be slightly confusing for the beginners. When MOSS 2007 beta 2 was released I took me 2 days to find out how to render your own infopath document to browser.

The steps for this are below:

§ Complete the publishing wizard (using the SharePoint option) and publish the form to a shared location

§ Launch the SharePoint Central Admin page

§ Select Application Management

§ From the InfoPath Forms Services section select Manage Form Templates

§ Click Upload Form Template

§ Click the Browse button and navigate to the shared location where you published the form

§ Highlight the form and click Open

§ Click Upload

§ Assuming the template uploads successfully, you will be returned to the Manage Form Templates page. Click on the uploaded template and select Activate to a Site Collection

§ If the Site Collection box has the correct site, click OK. If not, click the site and you will be able to change to the correct site.

§ Once the activation has completed, you can now associate the form with a form/document library

§ Navigate to/Create a form or document library

§ From the Settings button, choose Form (Document) Library Settings

§ Select Advanced Settings

§ For “Allow Management of Content Types” choose Yes and click OK

§ You should now see a new section called Content Types – click “Add from existing site content types”

§ Drop down the box and choose Microsoft Office InfoPath

§ From the “Available Site Content Types”, highlight the form you activated, click Add and then click OK

§ Test!

Mail me your comments and suggestions.

kick it on SharePointKicks.com