Thursday, June 21, 2007

Call for beta testers! Enhanced Content Query Web Part

This is to call beta testers. I want to kick the ECQWP project to beta2, which requires beta testers to start testing and reporting on Beta 1 (well, 1.3 actually) .
You don't need to write to me or anything - just get a free codeplex account, and use it in the ECQWP project site to add issues (bugs) to be fixed, or ask for enhancements.
Please try to be VERY clear on the problem - preferably with a step by step of what I need to do to get the error you are describing.

While I am at it, if you are a good SharePoint developer and you think you have the ability to solve the bugs, let me know, and I will add you to the project as a developer, and assign bugs for you to fix.
Please note - this is not a practice run. I do not have time to mentor beginners, so don't use this as a free training exercise. Sorry.

Wednesday, June 20, 2007

Adding custom fields to the Enhanced Content Quey Web Part (Beta 1.2)



I just got around to adding another important feature to the Enhanced Content Query Web Part and I uploaded it to codeplex.

I am sure you read my articles, or articles by other MVPS like Heather about showing custom columns in the content query webpart. This requires (as Heather's article shows) that you export the web part to a file, manually modify the file to add the fields you want, and import it back.

This annoyed me enough to add a property to my ECQWP that will allow you to add those fields without having to export-import.




In this version (1.2) you have two new properties in the propeties pane - Data Fields and Common View Fields. I have yet to find out how Data Fields are used, so you don't need to use that property - it is enough that you set the Common View Fields.

I will refer you to Heather's article to find out the format that the value of this property should be written in - how to get the field's internal name, and how to get the field's type. Just a quick reminder though - the value in that field is a pipe seperated value of fields, where each field is a coma seperated pair of field (internal) name and field type.
For example, a text field with internal name "Comments" will be added like so:

Comments,Text

A choice field with internal name "Client_x0020_Name" will be added like so:

Client_x0020_Name,Choice

and if we want to add both of the above fields, it will look like so:

Comments,Text|Client_x0020_Name,Choice





As always, get the web part, installation instructions and source code from codeplex. Just be sure to download the most recent version.








Tuesday, June 19, 2007

Enhanced Content Query Web Part upgraded to Beta 1.1

I am happy to announce that the Enhanced Content Query Web Part project has progressed to Beta 1.1, with some very important fixes to major bugs.


The web part now correctly prints out the item ID, has context menus for folders (not just documents) and supports displaying icons for documents.


Be sure to read the documentation (installation instructions) and use the new XSLT that is provided there. The old XSLT will not solve any of the bugs I fixed.








Community Kit for SharePoint 2.0 Pre-Release

You can read about it in the SharePoint team blog - there are some pre-release components from the Community Kit that are ready for download.
The downloads are:
Enhanced Blog Edition Beta 1
Enhanced Wiki Edition Alpha
ChatterBox AJAX Beta
Tag Cloud

Wednesday, June 13, 2007

Using Javascript to Manipulate a List Form Field

This is something I have been doing for a while (see my nested tasks project - it has been using this trick), and now Rob Howard from Microsoft published a tip on how to use javascript to manipulate a list form field.
The example of use I would like to give is my nested tasks project- we need to set a default value when a user creates a sub task. We have a web part sitting in the "newform.aspx" page, and checks the querystring the page was opened with. If the page was opened with a querystring of "parentID=", then it loads the item that is the parent, gets the values for start date and end date, and then uses javascript to set the "Parent Task", "Start Date" and "End Date" fields.
My javascript also hides the "Parent Task" field control from the user, so he will not edit it manually. This gives us a very user friendly interface.

The same trick can be used to implement some custom validation - for example not allowing the user to enter a start date before the start date of the parent.

Wednesday, June 06, 2007

My favorite tool just got better!

U2U have released a new version of the U2U CAML Query Builder, and this time it can be installed as a feature, and has a web interface instead of the windows form application it was so far. GREAT!
Check out the post from Karine Bosch.
If you don't know what the CAML Query Builder is, I suggest you start by downloading it (either the new release or the old one) and see how easy it is to write CAML queries with it.

Allowing InfoPath forms to redirect to pages in other site collections

In InfoPath 2007, when you publish a form as a web form, you have the option to specify several query string parameters. One of those parameters is the "Source" parameter, which is "The location to which the user will be redirected when the form is closed. The URL must be in the same site collection or an error will be returned."
The error mentioned is "The following location is not accessible, because it is in a different site collection:" and the url you specified.

So it seems that specifying a source from another site collection is impossible. But what if I have a site collection dedicated to forms? lets say "http://forms", to which I link from the intranet home page or another page, and I want that when the user closes the form, he will be redirected back to the page in the intranet (lets say "http://intranet") that we started from?

I had to come up with a solution, and a simple one jumped to mind - a redirect page!
The trick is simple. Instead of specifying a link to "http://intranet" as the source parameter (which will cause an error), specify a link to a special page in the layouts folder, and give that page the query string that links to the page you want to return to.

Confused? here is an example:
Instead of linking to the form with this link:

http://forms/_layouts/FormServer.aspx?XsnLocation=http://forms/myforms/Forms/template.xsn&Source=http://intranet

Link to it like this:
http://forms/_layouts/FormServer.aspx?XsnLocation=http://forms/myforms/Forms/template.xsn&
Source=http://forms/_layouts/SPSTipsFormRedirector.aspx?target=http://intranet

As you can see from the links, the first one will cause an error because we are linking to another site collection, while the second one will work, because we are linking to the current site collection.

So the only thing left for me to show you is how to create the SPSTipsFormRedirector.aspx page that will handle the redirect to the page you specified in the red section in the second link:
Open your layouts folder (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS) and create a new text file by the name SPSTipsFormRedirector.aspx. Open the file in a text editor such as notepad, and copy the following code:

<%
string target = Page.Request.QueryString["target"];
Page.Response.Redirect(target);
%>
<%
@ Page Language="C#" Inherits="System.Web.UI.Page" %>
<html>
</
html>

Repeate this in every front end server, and you are ready to write links to forms that, when closed, will go back to a page you specify in the link!

Tuesday, June 05, 2007

Enhanced Content Query Web Part goes Beta 1!

Hey Everyone!
This is to let you know that I released beta 1 of the Enhanced Content Query Web Part Project. Make sure you read the installation documentation to the end, because that is where you will find the sample XSLT that will cause the menus to appear.

Anyone want to volunteer to draw me a logo? Contact me!

Monday, June 04, 2007

Coming Soon! Content Query Web Part with Context Menus


Well, I promised you something that will knock your socks off, so hold on!

I have started a new open source project for an Enhanced Content Query Web Part that will have the enhancement (in the first stage) of Context Menus.

(note - the project is not yet published - I need to figure out why my laptop suddenly refuses to connect to codeplex, and I will release the beta)



Content Query Web Part for MOSS with Context Menus



Additional features that will come with this release include the ability to add the default toolbar (new, updload, actions, settings) to the web part when it is connected to a specific library or list (not in aggregation mode)

Content Query Web Part with Toolbar

Some things will not work as you'd expect (if you select a view using the view selector it will redirect you to the view, not change the current web part) but it is a very useful addition to the web part's abilities!




I intend for this project to grow to be a true replacement of the content query web part, and that is why I am calling this project "Enhanced Content Query Web Part".

I hope others who have done work around enhancing the built-in web part like Meron Friedman (Content Query Web Part with marquee) and Steven Van de Craen (extended Content Query Web Part with item limit per group *link seems to be broken?*) will join me as developers on this project, and integrate their code with mine.


I am also looking for advanced developers to help me get my current code stabilized. If you want to help - contact me.







Why isn't there a default value for lookup fields?

Oh, lookup fields, how I hate you.
I just realized that it is not possible in the user inteface to set a default value for a lookup field. Is it that hard to do an interface that will show the user creating the field the options from the looked-up list and allow him to select a default value?
Apperantly it is. I guess Microsoft were worried about what happens if someone deletes the looked-up value.

Not content with my findings, I tried looking in the object model and discovered that you can set up a default value for a lookup field using the following code:

SPList docs = w.Lists["Documents"];
SPFieldLookup fl = (SPFieldLookup)docs.Fields["City"];
fl.DefaultValue = "1;#Mexico City";
fl.Update();

I will add this option to my Utility Pack when possible.

Using the above code solves the issue almost totaly. When you use the web interface to add a list item or upload a document, the default value comes up in the lookup box. However (and this is the big one), from the office applications (both 2003 and 2007) the default value is ignored and the lookup box always begins at the "blank" option.

Should I waste one of my MSDN support calls on this and ask MS for a fix? or should I just learn to live with it?