Querying the “Person or Group” field using SPQuery (Update)

One of the weak points of Sharepoint 2007 is documentation. If you want to query a "Person or Group" field, the documentation on MSDN is a bit sparse.
Here is how to query a person:

<where>
  <eq>
    <fieldref name="PersonFieldName"/>
    <value type="User">User Display Name</value>
  </eq>
</where>

Replace PersonFieldName with the internal Name of the Field.
The two important things here: Value Type is "User", and the String to search for is the Display Name. So if you have a user called "John Doe" whose login is "mydomain\jdoe", you have to search for "John Doe", not for "mydomain\jdoe".
There is an obvious drawback to this: What if you have two users called John Doe?

Sharepoint People or Group SettingsI was quite disappointed that the Person field does not store the LoginName by default and can therefore not be queried for it.
There are two workarounds. The first one: Go to the properties of the field in the list, and at the bottom you can change "Show Field" to "Account".
This has the advantage that you can use the "domain\username" Syntax now. The drawback: The field looks bad in the list as it does now show the Login, not the Display Name with the neat presence status.

The second workaround: Use the undocumented LookupId property and search for the numeric ID:

<where>
  <eq>
    <fieldref name="PersonFieldName" LookupId="TRUE"/>
    <value type="int">UserID</value>
  </eq>
</where>

The UserID is not the "domain\username", but the numeric internal ID (SPUser.ID). As I use this in a workflow, I can easily access this through workflowProperties.OriginatorUser.ID, which is good enough for me.

Update: The second code example was incorrect, I fixed it now.

Gordon Freeman Calls Coast to Coast AM

Normally I dislike randomly linking YouTube Videos from a Blog, but the Gordon Freeman Prank made my day 🙂

Xbox 360 and Achievements (and Undertow)

So, I got myself an Xbox 360 the other day. While one of the primary reasons to get one was Microsoft's XNA, I also learned to like Xbox Live and Xbox Live Arcade. The Xbox 360 is not marketed as a "Casual Gamer" system (the Wii tightly holds that spot, and I don't think that Microsofts attempt to market the Xbox 360 Arcade console in that segment are too successful), yet some of the best casual games are available on there.

I played around with the Demo versions of Geometry Wars and Pac-Man Championship Edition, and I absolutely love them. Ironically, I like them so much because of the artistic style of the graphics, something that normally only Nintendo gets right. Yes, the Xbox 360 is a Triple-Core System with a nice graphics unit and Geometry Wars is possibly not using even 10% of the resources (wild guess), but it just delivers instant fun for a few minutes, or a few more minutes.

These are not the only examples, have a look at Sensible World of Soccer (SWOS) or Speedball 2 for other enhanced versions of the original games. The nice thing: For every single game, you can download a demo version for free. That way, you can test the games first. Most demo versions are quite lenient: They are usually with a time limit, but you can still play the game to make a judgment call on it.

I think that Microsoft got Xbox live well. Really well. Apart from it's stability apparently. Due to some recent problems with connectivity, you can currently download the Game "Undertow" for free for a few days, even as a Silver member. The game is quite fun. I don't like it as much as some of the other games i've tested, but it's free, so I recommend trying it :-).

Now, there is something else that makes playing games on the Xbox 360 a bit more interesting. It's a feature that has no functional use whatsoever and is best describes as "E-Peen", or in Microsoft Terminology: Achievements and Gamerscore.

Basically, in every Xbox 360 game, be it Retail or Arcade, you can unlock Achievements to gain Gamerscore.Xbox 360 Achievements (1) The number of Achievements varies from game to game - Perfect Dark Zero has 50 Achievements, Tomb Raider: Legend has 33, Forza Motorsport 2 has 44 etc. You can pick up some Achievement by simply playing the game (i.e. some games give you an Achievement every time you complete a level), some require more sophistication (i.e. getting all extras or beating time trial modes) and some are simply cruel (Dead Rising's "Zombie Genocider" which requires to kill 53,594 Zombies) or otherwise memorable (Six Degrees of Small Arms...).

Xbox 360 Achievements (2)As said, each Achievement gives you Gamerscore.In every Retail game, you can get up to 1000 Points, and some games offer additional 250 Points through downloads. For Arcade games, you can get up to 200 points and then a few more through downloadable content on some games (I think 235 is the limit). Your Gamerscore is displayed on Xbox Live, and you can use services like MyGamerCard.net to get an image for your forum signature, your blog etc.Souvenance Gamercard as of 2008-01-24

So why are the Achievemets and the Gamerscore so nice? Why do they actually work? They are indeed absolutely useless from a functional perspective - You will not get any extras for a high Gamerscore, you can not buy stuff on the marketplace for it and they just seem to have the purpose to keep people playing. And they work.

I think it's because they return a sense of Achievement to the game (which means that they are appropriately named :-)). I remember the old daysâ„¢ when I finished a game and had that feeling that I surely did something great. I don't know when, but somehow this feeling got lost or at least weaker among the years as I grew up and played more and more games. Finishing a game was nothing special anymore. Possibly because the next game already waited around the corner and games do not have a half life (no pun intended) of more than 6 months. Now with the Achievements, there suddenly seems to be a reason again to finish the games or play them again. Why play Tomb Raider: Legend a second time on the "Tomb Raider" difficulty or Gears of War on "Insane", as you already saw all the content and story? Why waste 6 hours trying to kill 54000 Zombies in Dead Rising? Why even try to get the Mile High Club Achievement in Call of Duty 4? Because you get a Reward at the end. It feels satisfying to try something over and over again and finally see that "Achievement Unlocked" message appear. And you can then show that you unlocked the achievement. Yes, it is stupid and useless E-Peen comparison, but it's deeply statisfying.

So yes, I like my Xbox 360, and I believe that Microsoft got - from a functional specification - the whole thing absolutely right. An attractive library of games, more casual stuff through arcade, the addictive Achievement system and a controller that finally deserves that name. Who knows, were it not for the Red Ring of Death problem, maybe it's reputation would be a lot better? I'm happy that I got a console with the newer Falcon Motherboard, so I should not need a towel.

2008 will be interesting, as Sony could finally have some success with the PS3. As BluRay is about to win the HD War, maybe the PS3 will have a similar success as the PS2 solely because of the drive? I doubt so because the PS2 came when DVD was already established and just waited to grow, whereas the PS3 works more as a "market enabler" for BluRay. I have to say that I did not test Playstation Network (PSN) yet (as I don't have a PS3 and don't plan to buy one before at least Christmas) and therefore can not compare it to Xbox Live, so I do not want to judge the PS3 yet. At the moment, the lack of a fair number of "want-to-have" titles does not give me any reason to buy one, so we'll see.

But it's definitely nice to see that finally, different consoles work in different market segments instead of trying to occupy the same.

Game Packaging

Until a few years ago, Packaging for PC Games was very wasteful: In a big cardboard box, you usually found the manual and the game CD itself, along with some advertising and filler material, but overall, the box was 80% empty. But it looked damn nice, with the big artwork that you could proudly display on your shelf, kind of like Vinyl looks better than CDs because the size of the cover.

PC GamesBut as storage space in stores becomes more and more valuable, and as those cardboard boxes were rather expensive to manufacture and generally a big waste,  the industry switched to DVD Cases. While the cover artwork is still there, a DVD case just does not look as nice as a big box if you want to proudly display your taste on a shelf. Of course, boxes are not entirely gone, but they are mainly used for limited collectors editions nowadays.

I remember the uproar among gamers when this change first happened. About european gamers upset about being cheated on the Black & White game packaging (the US Version had a two-sided cardboard box, whereas the EU Version came in a DVD case - at least the cover was changable from black to white). Generally, the feeling was that you would get less for your money. In retrospective, these concerns seem somewhat silly. Sure, there were some games that packed a lot into the box, like artwork books, comics or keychains. But the majority of games still came with only the cd and the manual. So there was no real loss. But there was a big gain: Shelf space! Previously, I had to throw away some of the boxes because I simply did not have enough space. As a real gamer, it did hurt to throw away some of those boxes, but if you can't safely walk around your room anymore, you know that you have to change something.PS2 DVDs

Ikea has those nice Benno Shelves, which allow me to freely separate them to create compartments for CDs or for DVDs or for anything else. With the DVD Cases, this allows me to put dozens of games in the shelf without having to throw away stuff. So I believe that the move from Cardboard Boxes to DVD Cases was one of the best decissions the industry took in the last few years. Interestingly, the Computer Games industry was pretty much the only gaming industry that used non-standard packaging. If you look at the console games, you will notice that they had a common packaging since the early days. Every SNES Game came in a standard sized cardboard box that was not too big to waste too much space. Every Playstation Game came in a CD-sized casing - unfortunately, the default case was a bit taller that CD Cases, which means that they don't fit well in standard CD shelves, and that they look somewhat deplaced when places next to Playstation games that came in 4-CD Cases. Luckily, Sony learned when making the Playstation 2 and used standard DVD cases since then. Nintendo and Nintendo DS and PSOne GamesMicrosoft also started to use DVD cases beginning with the Gamecube and Xbox. Also, Nintendo DS Games come in a case that has the same height as a CD, so they fit perfectly within a CD compartment in the Benno shelf 🙂

I don't know if it's a coincidence that the packaging was standardized for console games since the beginning. Maybe it was due to some rule enforced by Nintendo and Sega? Maybe it was due to the wish of the retailers to make the best use of storage space? I really don't know, but I do not think that the console world lost anything by making sure all the boxes had the same size and shape.

The packaging that is used nowadays is also nice for protecting the media. With PC games, usually you had a jewel casGameBoy Advance Casese. But I also had games that came in a paper sleeve - not very impressive if you just paid quite a bit of money only to see it in a loveless packaging. Game Boy Advance games also came without any case, they were only covered in a bit of plastic wrap - the DS Packaging is a major step forward as you can keep the game in the case that can be properly opened and closed multiple tiems without danger to damage it. Also, the manual now has a proper place.  There is however onemajor drawback: As the GBA boxes were pretty much useless after unpacking them, you could use some poster strips to put them on the wall. With the reusable DS Cases, this is not really possible anymore.

This was a bit more elaborate that I first intended it to be, but if you think about packaging and look how games came to you in the past 25 years, it's a somewhat interesting subject to look at. How will packaging look like in 5, 10, 15 years? Some people say that games will not physically exist anymore in 10 years and that everything will be distributed digitally, something that services like Steam (finally) provide mostly flawless. Current generation game consoles (Nintendo Wii, Sony Playstation 3 and Microsoft Xbox 360) provide means to download games to the console, and broadband gets more and more common. Will we really see the end of physical products in the next years?

I don't know. I don't believe so. I like the advantages that Steam brings, but as a gamer and collector, not owning a physical product is not a nice thought. Also, imagine how many possible conversations would be lost if there were no physical cases to put on your shelf. How often did someone notice that you had game X on your shelf and started to talk about it? What would you put on your walls if it weren't for those nice GBA boxes?

The industry believes that the future of gaming lies online, and in this point I hope that they are wrong. Sure, Xbox live and Steam are two strong assets in that argument chain, but as long as companies like Nintendo prove that some of the best games are either single player (Super Mario Galaxy) or best played with a bunch of people in your living room (Mario Party, WarioWare), I still have hope that gaming will stay something physical.

Alien vs. Predator 2

Calling AvP2 a bad movie would not be fair. Oceans Twelve or Constantine were bad movies, and categorizing AvP2 together with such movies would be an insult for them.

If you watch an Action movie, you usually don't expect an intellectual challenge or a good plot. But when I think about recent Action movies, i think of Bruckheimer/Bay, and they did set a certain standard.

AvP2 is nowhere near that standard. Most of the time you see black Aliens fighting the black Predator in the middle of the Night or in buildings with no light - reminds me a bit of the Transformers Movie, but much much worse. Combine that undefinable action with the non-existance of a plot and you got 8 wasted euros for the cinema.

To add insult to injury, you have a wanna-be love plot twist with some annoying stereotype-blond girl and two guys. However, this love story has a happy end, as the girl and the bad guy die. (Well, pretty much everyone dies at the end, but it was very satisfying to see the annoying people die before)

So here is my recommendation: Do not watch this movie. Ever. If you really wonder what Alien vs. Predator could be, here are my recommendations:

  • Play the 1999 Video Game. That was actually pretty decent.
  • Get 2 TVs with DVD Players, watch the 1986 "Aliens" on one and the 1987 "Predator" on the other
  • Read the Comics on which this whole stuff is based on.

Accessing the Data in Sharepoint

I've been spending some more time investigating on how to develop applications in Sharepoint. As said earlier, one question is always: Where to store the data?

In a standalone ASP.net Application, I would obviously use a SQL Server or some XML Files, but both do not really seem fit with Sharepoint, as Sharepoint already has a mechanism for data storage - Lists and Libraries.

From here, it is worth looking at the White Paper for Microsoft's Fantastic 40. This document contains some information on how Microsoft built their templates, but to me, it also looks like Sharepoint is not made for "real" relational data management. I like the part where they use JavaScript to set an ID. Nothing against JavaScript, but that's not really what i'd like to use for anything important.

Jose Baretto has two interesting blog posts. One deals with Sharepoint Application development in general. For me, Point #2 was especially interesting:

When you develop your application, there's usually a database (or a few) that goes along with it. In the early stages of your application lifecycle you will define what data you need to store and that will end up in a set of tables somewhere. Your data architecture team will define what the data should be and your database team will eventually define the tables, columns and views you will eventually implement. In the end, your ASP.NET application will be tied to a database server somewhere by something called a connection string.

If you're using SharePoint, you get a place to store your data. No direct SQL Server access. No connections strings specific to your application. Instead of tables, you get SharePoint lists and libraries. You can create custom lists with custom columns that look a lot like the tables. You can also have links between lists like using lookup fields, which are very similar to a foreign key in a database table. When you deploy your application and create a new instance of it, the data elements are there.

This is nothing really new, just reassuring me that my plans for the data storage are indeed getting a bit more complicated. The only "good" way is to use Sharepoint lists, as they can be easily deployed without creating external dependencies. His second Blog post deals with deployment, and it essentially encourages the use of "no-code" whenever possible.

You should promote the use of no-code SharePoint applications. Those are the templates and solution definitions that are based purely in metadata definition, like columns, lists, views, pages and workflows that carry no custom code. If your package (templates and site definitions) has only XML/ASPX files and no assemblies, that a good indication that your risks are low.

It is true that this is more a security concern than a technical one, but from here I think i'll look into more ways to achieve my tasks with the built-in means of Sharepoint. This also means: No SQL. Instead, it is possible to use CAML (not to be confused with the programming language) to query data.

For CAML, Microsoft has documentation on MSDN, which i'll give a read next.

As said earlier, Sharepoint is an Application Platform. It is an interesting technology, even though sometimes I indeed have to question if it's really suitable for every business application. I'll guess i'll know when i'm done with my test project...

Sharepoint Link List #1

As said yesterday, I'm playing around with Application Development in Sharepoint at the moment. I've found a variety of good sites and blogs, so here is my first, mostly unsorted link list.

  • SharePoint is not the Holy Grail
    • A good blog posting about the fact that Sharepoint alone will not solve any problems - it's a tool, not a miracle
  • Development and Engineering practices
    • Before starting any development, this article has some nice information from someone who had to learn it the hard way 🙂
  • How solution deployment has changed development with SharePoint technologies
    • A posting about Solutions in Sharepoint 2007 and how to install them
  • What are Content Types?
    • Content Types are very important if you want to use Lists instead of "real" database Tables. This posting is specifically about Content Types in Document Libraries, but it gives a good general overview.
  • Simulate Parent / Child relations
    • If you use Sharepoint Lists instead of real database tables, this article shows how to simulate Master/Detail relations. Here, Content Types play a Key Role
  • Two Articles about List Events: Article 1, Article 2
    • This seems to be a bit outdated (mentions Beta 2 of MOSS), but still a good read. Essentially, when developing applications, keep in mind that the user might use the Lists.asmx Web Service to create new items. If you have all your application logic in a custom form, this may be the source of problems.

Disclaimer: All the links were valid when I made this post. This is the internet, so links might change over time.

Sharepoint 2007 Application Development

Sharepoint is an interesting product, because it's hard to understand what it actually is and does. It looks like a File Server with the ability to store Documents, yet it enables server-side Full-Text Search on those. It also looks like a Server Version of Excel or Access (which is actually partially true, it is intended as a Server for Collaboration) with the ability to store informations in Lists. And it also looks like an Application Server, with the ability to host Workflows.

But it's the Application Server Role that i find somewhat tricky. if you "only" want to share data or do Approvals, Sharepoint is really straight forward. Create a list, write a workflow, done. But what if you want to make something "funky" with Database-Relations? Here, Sharepoint has some limitations - but limits are there to be broken, right?

Chris Johnson looks at some ways to do "real" Application Development with Sharepoint. I find Option 2 and 3 a bit "awkward", but Options 1 and 4 clearly show that it can be done. (I don't like Option 3 because the SmartPart does not seem to be well maintained, as Godotnet is Phased out and I could not easily find another download link - certainly not a good promise to base development on). Option 4 is possibly the only one really feasible, even though it looks a little bit like a "hack" to me. But then again, The tree of software development must be refreshed from time to time with the blood of hacks and workarounds.

For me, there are still a few open questions. Like: Is it better to use lists to store the data, even though if the data is strictly application-internal? Or should a "real" database be used, thus adding a second database layer? I would prefer option 1 if feasible, because then the deployment is easier, and i don't have "hidden" data somewhere - absolutely everything is stored in one site. I lose a lot of what makes databases though, as in Foreign-Keys or most other Constaints. In terms ob Query/Join, i cannot use SQL anymore, but XML or CAML would work as a substitute in most cases. And what about deployment - is it possible to wrap such an application together as a Solution/Feature or as a Site Template?

I think i'll spend the next days with fiddling around with this. Too bad you can't use "real" versioning properly, but using the FileVersion will have to be sufficient then...

Souvenance – Open Source ASP.net Photo Album Software

As mentioned earlier, my search for an ASP.net Photo Album software was not very successful. My needs were rather basic: I want to be able to just upload my pictures to a folder without having to go through 20 Steps of uploading and adding them to some sort of Album. I want to be able to share Photos with my family and friends, without having to spend hours installing, configuring and managing the Album. I don't need a fancy Plugin-System that allows people to click on a Photo and order T-Shirts with that Photo printed on it. And I certainly don't need a database-backed system just to share a few Photos.

On the other Hand, static Pages are also not optimal. Sure, Adobe Photoshop Elements has a nice Export for a Flash Presentation, but adding/removing Photos is still a lot of work on static pages.

I found something for PHP a while back, phpGraphy. This was exactly what I wanted: I just upload my Pictures, and they are displayed. I can also create Users and restrict my Albums. No SQL Database, no complicated Setup, just straight-forward Photosharing.

Starting from the impression that phpGraphy gave me and looking at the available ASP.net Gallery Software, I immediately knew that I would write something on my own. The result is Souvenance, an ASP.net Photo Album Software that can be set up in 10 Minutes and does not require any database or any complicated configuration. I released the first Beta a few days ago, and someone already mentioned it in a list of 49 open Source projects. I have to say that i'm honored to be in a list with software like Audacity or xine. (The posting was also mirrored by a chinese Linux site and another Blog).

Anyway, if you are searching for a "zero-configuration" ASP.net Photo Album, give Souvenance a try. There is even a User's Manual available now! I'll also write more about the Development History later, first I have to finish Version 1.0 🙂

Open Source and .net – not really an ideal partnership

Open Source Software is one of the cornerstones of the modern internet, not only thanks to the Apache Web Server, but also (and in my opinion, mainly) through the vast amounts of Open Source Software that runs on these sites. Forums, Blogs, Photo Galleries - there are dozens of good Open Source programs. Yet arguably, most of them are nowadays written in PHP, including this very Blog which runs on WordPress.

There is nothing wrong with PHP (ok, actually there is, but that does not matter here), but I recently switched to ASP.net for work purposes. I love C# and ASP.net, among other things also because of the very strong built-in class library. So it felt natural to look for an ASP.net Blog Software and Photo Album to run an ASP.net website on.

Given the fact that this Blog is hosted on WordPress, you may have guessed that the search was not very successful. As Jeff Atwood puts it, Open Source is often a second-class citizen in the .net ecosystem.

There are indeed plenty of ASP.net Blog Systems - SubText, Community Server, BlogEngine.net, to name a few. I tried about 6 or 7 different ones, and I decided to stay with WordPress. Why? Because it is much more mature. With PHP, installation is normally a 3-step process:

  • Upload all files to your web server
  • run the install script
  • use the applications

With the ASP.net Blog Systems i've tried, installation is a process for the system administrator. Manually building Connection Strings and putting them in the web.config file? Having to create a separate IIS Application for the Admin Panel? Requiring dbcreate rights in the database? Asking for FullTrust? That's not how it is supposed to be!

I don't know if .net Developers in general consider themselves "Elite" or "Enterprise Developers", but you can clearly see a different philosophy. Warning: I am generalizing here, there are always exceptions, and this is only my personal opinion.

.net is obviously associated with Microsoft, so I see a lot more "commercial" attitude. The installation is a lot more complicated, you have all sorts of weird requirements, and the amount of "free" information that can be dug up by google is rather sparse. PHP is associated with your typical Linux Hacker, which is why there is even the acronym "LAMP" to describe your standard Setup of Linux, Apache, MySQL and PHP. PHP does not seem to be as polished as .net, it looks a lot more like "organic growth", with all it's pros and cons. But the available PHP Applications seem a lot more polished and it is no problem to find a wealth of good PHP Code and Tips by Google. (Of course, you can also find a lot really really bad PHP Code on Google)

It feels a bit awkward to associate Microsoft with Open Source, even though they now seem to be a bit more serious about it. But that should not prevent anyone from making great Open Source Applications with .net Technology. Paint.net is one example of great .net Open Source Software.

Coming back to my original plan to find an ASP.net Blog Software and Photo Album, I have given up finding one. Instead, I started to make my own now. My Photoalbum - Souvenance - is now in Beta and should be released soon. I will then continue to work on my own Blog Software. More information on that will follow later.

   Newer→