Wednesday, May 30, 2007

Another reason for "the virtual server that is referenced here is not in the config database."

If you get the error "the virtual server that is referenced here is not in the config database" when you try to use object model, and if the microsoft KB article didn't solve it for you, and you are totaly may have the same problem I have - lack of attention.
This error appeared on my screen because I was developing on a server that has both sharepoint 2003 and sharepoint 2007, and in my project I referanced (without noticing) the DLL for WSS2 and not WSS3.
So ofcourse the code would throw an error it can't find the virtual server in the configuration database! it was looking in the wrong configuration database!
HA!, what a silly person I am...wasted half a day trying to troubleshoot this - going into the database, rebuilding the sites, rebuilding the application, extending the sites, mucking with IIS...untill I noticed the path to the DLL has "60" in it.

Monday, May 28, 2007

Meanings of variables in the context menu's script

If you are building a web part that displays context menus for list items - just like the context menus that SharePoint builds out of the box, you need to know the meaning of the attributes that you need to add to the table that holds the item. I couldn't find any documentation or referance to it on the internet, so I decided to publish the results of my diggings.
If you look at the source html of the built-in web part,you will see that every item with a context menu looks like this:

<table height="100%" cellspacing="0" class="ms-unselectedtitle" onmouseover="OnItem(this)" id="1"
icon="icdocx.gif|Microsoft Office Word|SharePoint.OpenDocuments"

The question is asked - what do those attribute mean? what is "cout" and what is "otype"? what values are expected there?

After some research, here is my dictionary:

  • ctxname: Name of the context object on the page that holds the context for the list that you are connecting to.
  • url: link to the document (can be either relative or absolute.
  • dref:File Directory Referance - the relative folder path the item\document is in. For example if I have a document library called "documents" with the url "http://portal/documents", the items in the root folder will have "documents" as the dref value, while items in a folder called "test" will have "documents\test".
  • perm: has to do with permissions, but I didn't figure out how it works yet.
  • type: Seems not to be used for items - but to create menu seperators or different kind of menus.
  • ext: The document extension. For example "doc", "docx", "ppt" and so on.
  • icon: This seems to control the "edit" menu item. Here you specify the icon that will be displayed next to the "edit in..." menu item, the text that will appear as the name of the application (edit in Microsoft Word) and the script that will be used to edit the item (I have no idea what possible values can be used here). All of this seperated by the "|" character.
  • otype: Current Item FSObj Type. This seems to have something to do with the check in-check out menus, that will not be displayed if this is 1, but I could not figure out what is the logic here.
  • COUId: Current Item Checked Out User Id. (ID of the user in the web site the item is from)
  • sred: Server File Redirect. Allows you to specify a URL that will be used instead of the file's url when the link is clicked or when a menu option is used. For example, if you put a link to another document, all menu actions will be redirected to that document instead.
  • cout: Current Item Checkedout To Local. If the item is checked out to a local (offline) folder and not to the database. 0 for false, 1 for true.
  • hcd: Controls if a menu item to navigate to the "/_layouts/updatecopies.aspx" will be added. I am guessing this has to do with records management (update copies of the document when it was changed).
  • csrc: Copy source link. If the item is a copy of an item in a records management site, this holds the link to the source, and adds the menu item for going to the source file (Go to source).
  • ms: Current Item Moderation Status. Also has to do with if its checked out or not, and if its draft or not.
  • ctype: The type of the item. I could not find where that is used.
  • cid: Content Type ID. The ID of the content type for the item. also seems to be used for list menus to determine the content type to create when a user clicks on the new item menu.
  • uis: Current Item UI String. Seems to hold the version number, where the major version is a multiplication of 512, and the minor version is the reminder (the script gets the minor version number by doing "%512"). For example, a value of 512 is version 1.0 while 513 is version 1.1 and 1024 is version 2. Does this mean we have a version limit of 511 minor versions in sharepoint? According to the "introduction to versioning", this is only the default and the administrator can change this. This sounds fishy considering the "512" limit is hard coded in the javascript.
  • surl: Source Url. This dictates where the page will go back to after a menu item is clicked.

Sunday, May 27, 2007

On my dashboard

Just a couple of valuable links to pages I always print out and hang in front of me when I am in a new cubical - a list of SharePoint URLs to get to commonly used administrative functions on a SharePoint site:
SharePoint 2003 URL Quick Links and SharePoint 2007 URL Quick List.

Thanks as always to Heather Solomon.

Wednesday, May 23, 2007

Content Query Web Part xsl for showing the xml

I keep forgetting this, and I think I had to figure it out from scratch at least 4 times allready, so I may as well blog it.
The thing is - last time I figured it out I wanted to blog about it, and then saw that someone beat me to it - Heather Solomon already wrote about it in her blog, and I seem to remember someone else wrote a similar script.
The thing that throws me off every time is realizing that the XML that the content query web part builds for each item has the values in the attributes. So what you need to do is write xslt code to display the attributes.

Heather's article says exactly how to modify the files, so if you need that kind of help, go there now. Below is the code that I am using (slightly modified):

<xsl:template name="ShowXML" match="Row[@Style='ShowXML']" mode="itemstyle">
    <xsl:for-each select="@*">
        Name: <xsl:value-of select="name()" /> Value:<xsl:value-of select="." />

I have just managed to do something really cool with the web part, but I have to refine it a bit before I publish it. I promise this will knock your socks off!

Thursday, May 17, 2007

Mike Fitzmaurice in Canberra

We had a perfect user group meeting here yesterday, with a record breaking number of 65 attendees!

Mike Fitzmaurice, the "developer evangelism contact in Microsoft" gave us 1.5 hours of pure Q&A.
It was very interesting and questions flowed.
Thanks Mike!

Sorry for the poor picture quality - I was there with only my phone...

If you are interested in coming to future user group meetings, go to the registration page in our web site, or let me know. I am now managing the user group, and would love to hear from you what you want to see and hear in our meetings.

What a discount!

This is something a friend noticed when we went to look for an LCD screen for him. What a great discount!

I think you will find this is less then 0.1% discount.

Friday, May 11, 2007

SharePoint Designer Article 2 - Creating an XSLT DataView for a sharepoint list

An XSLT dataview is a great way to modify the look and feel of displayed data in a sharepoint site. The dataview web part is able to display data from either sharepoint lists, or from external data sources.

This article will focus on how to create a simple xslt dataview for a sharepoint list.

First we will create a sharepoint list - Contacts, and fill it with some sample data:

Now, lets create a new page that we will use to create the xslt dataview in:

Open the page in SharePoint Designer (see my previous article if you forgot how - you will need to detach it from the page layout first!).

Now we can add the contacts list to the page using sharepoing designer. You can also do that from the browser before opening the page in sharepoint designer if you prefer:

Let us work in a clean environment - change the properties of the web part so it doesn't display the toolbar. Annoyingly, in sharepoint designer this means you have to open the dropdown menu for the web part (looks like a list icon) and select "change layout":

Select not to show a toolbar.

Now we can transform the web part to an XSLT dataview. Just right-click the web part and choose "convert to xslt data view":

The page should flash and then the web part will appear again, only slightly different. A new menu will appear with a lot more options (filter, sort and group, paging, edit columns, change layout, data view preview, show with sample data, conditional formatting, web part connections, parameters, refresh dataview, dataview properties).
Now you can start playing with it!

In this article I will not go over all the options - I will just conclude by showing you the conditional formatting, and how to deploy the web part to another page in the site:

Click on "Conditional Formatting" in the common data view tasks menu:

The task pane on the right should change to the "Conditional Formatting" pane. Now we can click a row (any will do), and then click the "create" menu, and choose "apply formatting" from the menu:

Because we selected a row, we can apply formatting to that row based on rules we will now define in this screen:

In this example I chose the rule - when first name is "Ishai". Press OK to get to the formatting options:

I set the formatting to show my contact's row with a light blue background, in bold and in uppercase.

Save the file, and view it in the browser:

As you can see - it shows exactly what I wanted it. Now to deploy it to the home page of the site (which we didnt want to detach from the layout page):

In the browser, open the actions menu for the web part and click "export":

Now save the file to your desktop, and go to the homepage of the site. Switch to "edit page mode", click on "add a web part" in one of the zones, and then on the "advanced web part gallery and options" link at the bottom.

Use the dropdown at the top of the pane to switch to web part import pane:

Now, browse to the saved file and click the "upload" button. The web part should appear as an option in the pane. Drag and drop it to the zone you want it in:

And now you can click on "Exit Edit Mode" and see your wonderful new home page, that is still attached to it's layout page!

The next article will show how to do the same, but with external data!