Saturday, December 23, 2006

Opening Infopath forms in Browser directly from a link

Many people have faced the problem of not been able to open Infopath form in browser in

MOSS 2007 directly from a link to .xsn file other than Form library itself. If the user tries to open an

.xsn file from the form library which is configured to render the form in the browser, the user

gets a open/save dialog box instead of a form being rendered in browser.

This is because the links clicked inside a form library or document library behave differently

than the link to same target clicked on any other page. An Office compatible client like Word 2007,

Excel 2007, InfoPath 2007 is smart enough to detect that the link is opened from Document library and

when it detects such a link click, it automatically opens the document directly from the document library

without showing the open/save dialog box in the browser. If you try to modify the document, the

document will be saved directly to the document library. This behavior of document library is identical

to that of normal Windows folder.

The solution to this problem is to have a link to URL (when the form is rendered in browser) rather

than having link to xsn file itself.

This solution is not suitable if you have a link coming in dynamically for ex. for each form in form library,

there is a link in your custom webpart. However you can easily avoid this problem by writing a simple

code which will incorporate the filename of your form in the URL.

Cannot find Data Connection Library in WSS v3

If you are wondering, when you go to create page in your sharepoint site and cannot see

Data Connection Library option there, most likely, you do not have MOSS 2007 installed.

Data Connection Library is a document library which lets you hold you data connections like

Office Data connection files which hold connection string pointing to your external data.

This feature is only available in MOSS 2007. If you are using WSS v3 only, you are out of luck J

If you have MOSS 2007 installed and still there is no option of creating Data Connection Library, you
are most probably using a team site template. Data connection library is not activated as a feature in team site.

So better solution would be to create site out of Publishing Portal or Collaboration Portal.

Wednesday, November 29, 2006

Determining the Current User Context inside Sharepoint
 
What's the best way to determine the current user within a custom web part
developed for MOSS 2007?  I've found four solutions so far, but I'm pretty sure
there are more:

1. Use System.Web.HttpContext.Current.User.Identity.Name, like in any 
    ASP.Net web application


2. Use System.Security.Principal.WindowsIdentity.GetCurrent().Name


3. Have the Current User Filter send the current user to your web part,
    and (of course) make your web part a consumer of that value.

4. SPWeb web = SPControl.GetContextWeb(Context); 
    SPUser currentUser = web.CurrentUser;

Monday, November 27, 2006

Resolving : Server is either too busy or not responding in SQL Server 2005 Analysis Services
 
I recently faced this error while connecting to Microsoft SQL Server 2005 Analysis services from Microsoft
Excel 2007. Inspite of the several solutions given on various sites none of them seemed to work.
 
The solution was simple, you need to install Microsoft OLE DB Driver 9.0 for SQL 2005, old 8.0 drivers
doesnt work.
 
To install the driver go to this page :
 
and choose the appropriate download. Note that the download needs to be installed for every client access machine.

Wednesday, October 04, 2006

Virtual PC SP1 Networking problems (address "00:00:00:00:00:00" failed to initialize)

 

There have been a number of people reporting that when they start a virtual machine - they get the following error:

The network adapter with address "00:00:00:00:00:00" of virtual machine "...." failed to initialize because the address is a null address.

To fix this problem you should use REGEDIT to:

  1. Examine the key value at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\<nnnn>\DriverDesc to locate the desired host adapter where <nnnn> is a four digit number.
  2. Look at the GUID value for the NetCfgInstanceId key value.
  3. Add the DWORD key at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VPCNetS2\Parameters\Adapters\<guid>\Flags and set the value to 0 where <guid> is the GUID found in step 2.
  4. Restart the computer.

If you want to see the details of this error see

http://blogs.msdn.com/virtual_pc_guy/archive/2005/01/17/354971.aspx

Monday, October 02, 2006

Code names from MS

 

Ø Longhorn (code name): The next major release of the Microsoft Windows operating system.

Ø Avalon (code name): Graphics presentation technologies in Windows "Longhorn" that provides a unified architecture for presenting user interface, documents and media in the system.

Ø ClickOnce: Technology in Windows "Longhorn" designed to speed & simplify deployment of applications.

Ø Indigo (code name): .NET communications technologies in Windows "Longhorn" designed to build and run connected systems.

Ø SuperFetch: Technology in Windows "Longhorn" designed to help applications launch more quickly.

Ø Whidbey (code name): Next generation of the Microsoft Visual Studio system of software-development tools.

Ø WinFS (code name): Next-generation search and data storage system that provides a unified storage model for applications running on Windows "Longhorn."

Ø WinFX: Programming model Windows "Longhorn," used by software developers to build applications for the Windows platform.

Ø Yukon (code name): The next generation of Microsoft SQL Server database software.

Sunday, September 03, 2006

Site Definitions Demystified - Creating a custom site definition having Custom webparts

There are two confusing terms in MOSS 2007, site templates and site definitions.

 

A site template is a .stp file which contains only the difference of changes from the

Original site definition. A user wants to install a custom .stp file must have a site

Definition installed from which the .stp file was saved.

(Note: In MOSS B2, you can only save top level sites. i.e. site collection as a site

Template. This is a bug and will be corrected in B2TR.)

 

A site definition on the other hand is a complete definition with a directory structure

Containing .aspx files and important Onet.xml file.

 

We will create here a simple site definition which when applied shows a custom webpart

On page.

 

The site definitions are stored in this directory

\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates

 

Each site definition needs an entry in webtemp*.xml file which are located here

\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML

 

To begin with:

 

Make a copy of this directory

Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates\sts

In the Site Templates directory and name it sample. This will create a site definition named sample having the

Same structure as team site i.e. sts directory.

 

Now to make it appear in the create site list, create a file named webtempsample.xml in the directory

\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML

And paste these contents

 

<?xml version="1.0" encoding="utf-8" ?>

<!-- _lcid="1033" _version="12.0.4017" _dal="1" -->

<!-- _LocalBinding -->

<Templates xmlns:ows="Microsoft SharePoint">

<Template Name="SAMPLE" ID="10001">

<Configuration ID="0" Title="Sample Site" Hidden="FALSE" ImageUrl="/_layouts/images/stsprev.png" Description="This sample template creates a site for teams to create, organize, and share information quickly and easily. It includes a Document Library, and basic lists such as Announcements, Calendar, Contacts, and Quick Links." DisplayCategory="Custom Site Definitions" >    </Configuration>

 <Configuration ID="1" Title="Sample Blank Site" Hidden="FALSE" ImageUrl="/_layouts/images/stsprev.png" Description="This sample template creates a Windows SharePoint Services-enabled Web site with a blank home page. You can use a Windows SharePoint Services-compatible Web page editor to add interactive lists or any other Windows SharePoint Services features." DisplayCategory="Custom Site Definitions" >    </Configuration>

<Configuration ID="2" Title="Sample Document Workspace" Hidden="FALSE" ImageUrl="/_layouts/images/dwsprev.png" Description="This sample template creates a site for colleagues to work together on documents. It provides a document library for storing the primary document and supporting files, a Task list for assigning to-do items, and a Links list for resources related to the document." DisplayCategory="Custom Site Definitions" >    </Configuration>

</Template>

</Templates>

Reset the IIS and try creating the new site. We will get a custom tab while choosing the site definition which

Three choices.

 

Now the important bit, we will now modify the site definition file onet.xml and place a custom webpart in the definition

So that when site definition is created, a custom webpart appears on the page.

I assume we have a custom webpart .dll and .dwp file ready.

 

Open the onet.xml file from

\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates\sample\xml

 

This is the main file of the site definition and it stores the structure of whole site definition.

Observe this section of the file, the <modules> tag.

  1. <Modules>
  2. <Module Name="Default" Url="" Path="">
  3. <File Url="default.aspx" NavBarHome="True">
  4. <View List="$Resources:core,lists_Folder;/$Resources:core,announce_Folder;" BaseViewID="0" WebPartZoneID="Left" />
  5. <View List="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder;" BaseViewID="0" RecurrenceRowset="TRUE" WebPartZoneID="Left" WebPartOrder="2" />
  6. <AllUsersWebPart WebPartZoneID="Right" WebPartOrder="1"><![CDATA[

<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2" xmlns:iwp="http://schemas.microsoft.com/WebPart/v2/Image">

<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>

  1. <TypeName>Microsoft.SharePoint.WebPartPages.ImageWebPart </TypeName>

<FrameType>None</FrameType>

<Title>$Resources:wp_SiteImage;</Title>

<iwp:ImageLink>/_layouts/images/homepage.gif</iwp:ImageLink>

</WebPart>

]]></AllUsersWebPart>

  1. <View List="$Resources:core,lists_Folder;/$Resources:core,links_Folder;" BaseViewID="0" WebPartZoneID="Right" WebPartOrder="2" />
  2. <NavBarPage Name="$Resources:core,nav_Home;" ID="1002" Position="Start" />
  3. <NavBarPage Name="$Resources:core,nav_Home;" ID="0" Position="Start" />
  4. </File>
  5. </Module>

 

If we try to understand this section, we also have an .aspx file in our site definition directory. If we observe the .aspx

File, we will see that it defines two webpart zones, left and right . See the snippet below of .aspx file :

The ids of webpart zones are left and right respectively.

<td>

             <table width="100%" cellpadding=0 cellspacing=0 style="padding: 5px 10px 10px 10px;">

              <tr>

               <td valign="top" width="70%">

                     <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Left" Title="loc:Left" />

                     &nbsp;

               </td>

               <td>&nbsp;</td>

               <td valign="top" width="30%">

                     <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Right" Title="loc:Right" />

                     &nbsp;

               </td>

               <td>&nbsp;</td>

 

The onet.xml defines which webpart goes into these zones and the order of those webparts. If we see the line number

Five above, it defines the right webpart zone and places the .dwp file of the out of the box ImageWebPart in the

CDATA section.

 

Now delete everything in the CDATA section and place the .dwp file of your custom webpart. We will also have to place

The .dll file in the web application bin directory.

 

 

Now again reset the IIS and create a new site based on this definition.

When we will create a site out of this customized site definition, we will get a custom webpart already created on the site

On the right zone.

 

There are lots of possibilities in customization of onet.xml file. We could have modified the left webpart and zone and

Place another webpart there. Or we could have modified an .aspx file and added more webpart zones.

If that's not enough, we could have added our own custom .aspx file and added its entry in the modules section of the

Onet.xml file. The possibilities are endless !

 

Mail me your comments and suggestions. I can mail the custom site definition discussed here to the interested.

Saturday, September 02, 2006

Localization in WebParts

Microsoft Sharepoint Portal Server doesn't have support of localization in multiple

Languages natively. The document at

http://www.microsoft.com/technet/prodtechnol/office/sps2003/maintain/spsinatl.mspx#E5F

 

Discusses this situation. It is clearly mentioned that

SharePoint Portal Server 2003 does not support a mixture of different localized portal servers on the server farm, nor does it support a mixture of different localized Windows Server 2003 servers. All servers running Windows Server 2003 in a farm topology must be in the same language, and all servers running SharePoint Portal Server 2003 in a server farm must be in the same language

 

Still, if you want to perform localization in webparts for whatever reasons, it is simple to do so.

We will create a simple MOSS 2007 webpart with localization support.

 

  • Create a simple class library project and reference to the sharepoint namespace.
  • Create a template of webpart
  • Now we will add a resource file to the project. Choose Add New file from the project menu
    And add a resource file for each of the languages. For example

Healthcare.resx

Healthcare.de.resx for German

Healthcare.fr.resx for French

 

Note that you cannot add App_GlobalResources to the project since it is only valid for the web sites

And not the class library projects.

 

  • Add the following reference to your webpart source file
    using System.Configuration;

using System.Globalization;

using System.Resources;

 

We will pick the language settings from the web.config file. Add the following tag to the

<appsettings> section of the web.config file of your sharepoint web site.

<add key=culture value="de-DE">

 

Add the following class variables to your webpart source file.

CultureInfo cult =  CultureInfo.CreateSpecificCulture(ConfigurationSettings.AppSettings["culture"]);

ResourceManager rm;

 

This will create a CultureInfo object based on the language settings in the web.config file.

 

In the constructor of your webpart add a line like this

rm = new ResourceManager("CustomWebParts.HealthCare", this.GetType().Assembly);

 

Where HealthCare is the name of your resource file ex HealthCare.resx and HealthCare.de.resx

And CustomWebParts is the namespace of your webpart.

 

Basically this line creates a resource manager for the specific resource file.

 

Now we will load all the strings which are used in the webpart source to the resource file.

This is fairly easy.

 

Now to load strings at any point in the webpart source we will use the GetString() method of

ResourceManager class. For Ex

 

protected override void CreateChildControls()

        {

            base.CreateChildControls();

            this.Title = rm.GetString("CarePlan", cult);

        }

 

This method sets the title of the webpart to the appropriate language based on the web.config file

 

The above localization is not specific to sharepoint instead it's an asp.net 2.0 feature.

I can mail the source code of the webpart to anyone if needed.

 

Send your suggestions and comments.

 

 

 

 

 

Sunday, August 20, 2006

Publishing Infopath form on Sharepoint Pages

The msdn document at

http://msdn2.microsoft.com/en-us/ms406041.aspx

shows us how we can host our infopath form in a custom aspx page or a Windows Application.

What I would show here is how you can display your infopath form on the sharepoint page.

The hosting of infopath form on a sharepoint page can be done with either two ways :

  • Using Sharepoint Designer and dropping a XMLFormView Control
  • Creating a Webpart for hosting the infopath form

We will be using the second method since it is more intuitive. To develop a simple webpart for

Hosting infopath form, we will create a simple Class Library in Visual 2005 and add a reference

to Microsoft.Sharepoint

The main code we will be writing is in the CreateChildControls section.

protected override void CreateChildControls()

{

base.CreateChildControls();

try

{

control = new Microsoft.Office.InfoPath.Server.Controls.XmlFormView();

control.XsnLocation = text;

this.Controls.Add(control);

}

catch (Exception e)

{

EventLog.WriteEntry("Office", e.Message + e.Source + e.StackTrace, EventLogEntryType.Error);

}

}

In the above code, we have created a XMLFormView control programmatically. This control is in

Microsoft.Office.Infopath.Server.Controls namespace and this dll is located in Office Server directory

In Program Files directory.

In addition to it, we can use a property which can take the location of xsn file on sharepoint site to host. We will create

A property called xsn

[Browsable(true),

Category("Miscellaneous"),

DefaultValue(defaultText),

WebPartStorage(Storage.Personal),

FriendlyName("XsnLocation"),

Description("XSN Location")]

public string Xsn

{

get

{

return xsn;

}

set

{

xsn = value;

}

}

And then we can change the CreateChild controls code to take the xsn file location from the

Property like

control.XsnLocation = Xsn;

I can mail the source code to anyone if interested.

Mail me your suggestions. J


kick it on SharePointKicks.com

Sunday, July 23, 2006

FW: SPS 2003 WebParts vs. ASP.NET 2.0 Webparts

 
ASP.NET 2.0 WebPart Framework is a new feature in ASP.net 2.0. Although Webparts existed in SPS 2003 times, this framework is completely new and follows its own architecture. The cool thing is ASP.NET 2.0 webpart framework is now compatible with latest version of sharepoint
i.e MOSS 2007.
This means ASP.NET 2.0 webparts can be used in Sharepoint 2007.

I wont repeat here the steps required to use your ASP.NET 2.0 webpart in Sharepoint 2007. You can see several blogs on this topic like:


http://weblog.vb-tech.com/nick/archive/2006/05/10/1563.aspx

http://msdn2.microsoft.com/en-us/library/ms431087.aspx


One main thing here to be kept in mind while creating custom webparts is that 2003 webparts dwp file uses different schema than Sharepoint 2007 webparts. If you try to use the ASP.NET webpart with old schema and try to import it in sharepoint you get the error:

The class does not derive from the Microsoft.SharePoint.WebPartPages.WebPart class and therefore cannot be
imported or used in a WebPartZone control

To resolve this ASP.NET webparts uses the different schema which is like this:

 

<?xml version="1.0" encoding="utf-8"?>
<webParts>
 <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
  <metaData>
   <type name="aspwebpart.FeaturePart, aspwebpart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
   <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
  </metaData>
  <data>
   <properties>
    <property name="Title" type="string">FeaturePart</property>
   </properties>
  </data>
 </webPart>
</webParts>




Using this schema you can easily import your ASP.net 2.0 webparts onto sharpeoint 2007.

The custom webparts you create can either be imported from
System.WEb.UI.WebControls.Webparts or Microsoft.Sharepoint.WebPartPages.Webpart

However if you plan to use feature like connections between webparts , you are left with
the option of using only deriving from Microsoft.Sharepoint.WEbPartPages.WebPart.

 


kick it on SharePointKicks.com

MOSS BDC MetaData Manager

 

                                                            MOSS BDC MetaData Manager

Atlast there is finally a MOSS BDC MetaData Manager using which you can create BDC XML’s

Using a GUI application. I have hard time creating BDC XML in past since B1 TR. This application

Is a treat for sharepoint 2007 users J

See the blog at

http://www.sharepointblogs.com/tbaginski/archive/2006/07/16/9259.aspx

 

Customization of Sharepoint Site

There are very few blogs on customization of Sharepoint 2007 site which involves direct editing uses master pages. Here is one of the few blogs which discusses this topic to the heart.

Sharepoint Tips And Tricks

Saturday, July 22, 2006

Microsoft Announces Beta 2 Technical Refresh

Microsoft in its beta site announced that it will be launching Beta 2 Technical Refresh in short time. Although not much info was available , but according to microsoft :

The B2TR (Beta 2 Technical Refresh) build will be releasing in the not too distant future and we’re starting to outline plans for that release. Over the next weeks we’ll be providing more information about what TAP members can expect in the way of deployment planning, Vista interoperability and support from our product development teams for B2TR deployments.

Saturday, July 15, 2006

For all those who want to develop WSS 2.0 webparts in VS 2005

The Sharepoint Diary: Sharepoint Web Part Library Project Template for Visual Studio 2005

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
http://msdn2.microsoft.com/en-us/ms778201.aspx

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);
fTextBox1.SetValue(Request.QueryString["CustomerID"]);
}

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