Wednesday, November 26, 2008

Tip! Yet another CAML query tool

CAML (Collaborative Application Markup Language) is an XML based markup language used with the family of Microsoft SharePoint technologies (Windows Sharepoint Services and Office SharePoint Server). Unlike plain XML, CAML contains specific groups of tags to both define and display (render) data. [wikipedia]

With other words CAML defines various aspects in SharePoint like: views, fields, site definitions, ...

With CAML you can also define queries, which is useful to extract some data from SharePoint lists. Now... writing a simple CAML query isn't that difficult. Given the following example:





It can be difficult if you have more conditional clauses:







Now I probably hear you say: "Sven, what are you talking about? I use the CAML query builder from U2U to construct my queries. That's pretty easy!". I know... that tool is really helpful but what if you have to construct your query dynamically? You can build a flexible query class to simplify the process of creating queries, but it's not necessary. Carlos Segura Sanz (MVP) did this already with his "Yet another CAML Query tool (ala SQL).

With that tool you can construct your query ala SQL. Later on, you can transform the SQL syntax to CAML syntax. Example:
using IdeSeg.SharePoint.Caml.ParseQuery;

string query = @" WHERE ContentType='sharepoint'
AND Firstname = 'Sven'
AND Lastname = 'Gillis'
GROUPBY Title DESC
ORDERBY _Author"
;
try
{
string camlQuery = CAMLParser.Query(query);
SPList list = null;
SPQuery query = SPQuery();
query.Query = camlQuery;
SPItemCollection col = list.getitems(query);
}
catch (ParserException ex) {}
Quite easy, isn't it?

Use "=null" as CAML IsNull operator and "<>null" as IsNotNull also you can use dates enclosed into sharp characters #01/01/1990# the sql Like operator is replaced by CAML Contains and the at "@" operator for the CAML BeginsWith. Also support parentheses for operator precedence.

Oh... btw if you download YACAMLQT you can also use a windows application to support your development. It looks something like this:


















I recently used it in a project and it works like a charm!

Resources:

Saturday, November 22, 2008

WCM: Publishing Site Definition

Creating a new publishing website typically begins by creating a new publishing site collection based on your custom publishing site definition. Nevertheless, it is not necessary to create a custom one because you can also start with the OOTB Publishing Portal Site Definition and then remove the parts that are superfluous. It is quite obvious that this method is not ideal. Starting off with the Blank Site Definition and activating the publishing features is a better option because then you have a quite clean environment to start with.

Probably the best option is to create a Publishing Site Definition from scratch. This way, you "almost" have full control of the provisioning process. Below a few examples which elements you can specify:
  • The welcome page url and the appropriate (custom) pagelayout
  • Automatically activate masterpage, styles, ... features
  • Available web templates
  • Automatically activate the ViewFormPagesLockDown feature - A special feature that restrict access for anonymous users to published content only
  • Alternate CSS url
  • And so on...
In one of my next posts I'll show you how to set a welcome page with your own pagelayout with a custom content type (specified in your publishing site definition).

Saturday, November 8, 2008

Off-topic: E.T.A.

Marvin has the most boring job - ever. But all is not as it seems...

Thursday, October 30, 2008

Access denied when crawling MOSS Content

Banging your head against your screen because you get the following error message...?

Access is denied. Verify that either the Default Content Access Account has access to this repository, or add a crawl rule to crawl this repository. If the repository being crawled is a SharePoint repository, verify that the account you are using has "Full Read" permissions on the SharePoint Web Application being crawled. (The item was deleted because it was either not found or the crawler was denied access to it.)

Try the following to fix this:

Disable the loopback check

Follow these steps:
1. Click Start, click Run, type regedit, and then click OK.
2. In Registry Editor, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
3. Right-click Lsa, point to New, and then click DWORD Value.
4. Type DisableLoopbackCheck, and then press ENTER.
5. Right-click DisableLoopbackCheck, and then click Modify.
6. In the Value data box, type 1, and then click OK.
7. Quit Registry Editor, and then restart your computer.


Source: http://support.microsoft.com/kb/896861

Saturday, October 25, 2008

Being a devigner can be hard...

Being a what? Well... Heather Solomon introduced this term a couple of years ago. I really agree with her that a SharePoint developer actually is a developer and a designer. On the one side this term makes my life a lot easier. Let me give you an example:

A: Hi, it's been a long time I saw you!
A: What are you doing for living?
B: I'm a SharePoint Developer
A: A what?

You can also say you are working with computers, but then most people will associate you with a salesman or a repairer ... like people in my neighbourhood think I'm a specialist in cleaning up some pc's, working with anti-virus software, etc. Looks familiar?

What if we had told A that we are a "devigner"? Do you think they will understand? Hehe... probably not. I think we just have to say "a software engineer" or for some of you "a software architect" or a "IT manager". But then they are probably not aware of that we also design some stuff. I give up :)

On the other side being a devigner is really hard. In that way that we have to deal with .NET (C#/VB), ASP.NET, SharePoint, CSS techniques and so on... We not only have to know when to dispose objects but also that css sprites are much better than separate images. We need so much knowledge that it is very difficult to become an expert in a specific domain. This fact is quite annoying but we all know SharePoint development is a steep learning curve - We have to deal with it ;)

Tuesday, October 7, 2008

How To: Embed PowerPoint slidedeck into SharePoint page

Do the following steps:

- Open a PowerPoint File
- Save As > Other Formats > Save as type Single File Web Page
- Upload the .mht file to a document library
- Add a Page Viewer WebPart to a Page
- Point the Page Viewer WebPart URL to the .mht file of that doc lib

Result:

Sunday, October 5, 2008

Tips to lure End Users to your SharePoint Portal

A lot of companies are already in possession of SharePoint, but I noticed that not every portal is equally popular. There are intranet / extranet solution who are barely used. It's a pity that they not take care of such a powerful product.

Below a few tips to bring life in your SharePoint Portal:
  • Optimize the information architecture of your site.
  • Analyze the needs of the users: It is important to have a general idea of the different types of users who will be accessing the portal.
  • One of the nice things about SharePoint is that it's relatively intuitive; you don't have to do a lot of training. In my opinion, this statement is not completely true. SharePoint is only partly intuitive if you are quite familiar with computers. SharePoint training for End Users is a must - Only then they will see the usefulness of SharePoint.
  • Don't ignore the look & feel. End users like to work in a neat environment.
  • Make your SharePoint implementation more user-friendly.
  • Make use of Web 2.0 elements like videos, wikis, RSS Feeds, weblogs, podcasts, ...
  • Add some cool features like quiz , document rating, polling webpart, ...
  • Make use of My Sites. It's always fun to play "Rate the picture" with some collegues.
  • Make sure the search engine is easy to use (cfr. Google). You can also extend the OOTB search functionality with faceted search, federated search or others.
  • Make use of statistic tools to monitor the usage of the portal (Site Usage Report, CardioLog, ...)