July 2008 - Posts
You have a calendar list. You want to query it for events that happen right now. Not today, not this week, right this moment. Yes, including reoccurring events. I really thought it would be easier, or at least hoped to find a working example somewhere...
Anyway, here is the CAML that I ended up with:
<Where>
<And>
<DateRangesOverlap>
<FieldRef Name="EventDate" />
<FieldRef Name="EndDate" />
<FieldRef Name="RecurrenceID" />
<Value Type="DateTime" IncludeTimeValue="TRUE">
<Today />
</Value>
</DateRangesOverlap>
<And>
<Geq>
<FieldRef Name="EndDate" />
<Value Type="DateTime" IncludeTimeValue="TRUE">
<Today />
</Value>
</Geq>
<Leq>
<FieldRef Name="EventDate" />
<Value Type="DateTime" IncludeTimeValue="TRUE">
<Today />
</Value>
</Leq>
</And>
</And>
</Where>
The first part gets all the events for today, including reoccurring events, and the second one checks for the time. Put the both inside <And> section, and you get all the events for now.
DatesOverlap is used to query for reoccurring events, it needs some configuring of the SPQuery object to work.
Here is how it all fits togeather in code:
SPList list = SPWeb.Lists["Calendar"];
SPQuery q = new SPQuery();
q.CalendarDate = DateTime.Now;
q.ExpandRecurrence = true;
q.Query = "<Where>...</Where>"; //Full CAML omitted for clarity, just paste the code from above
SPListItemCollection items = list.GetItems(q);
Hope this saves you the time I spent.
Problem:
You try to use a Data Form Web Part (Data View Web Part) to display a document library in an XSLT view. You find out that documents that include an apostrophe character (') in their file name, cannot be opened or viewed. (There might be other problematic characters beside apostrophe, I haven't checked that)
Steps to reproduce:
- Create a document library. Add some files with apostrophe in their name to the library.
- Click on one of those items. The file opens as expected.
- Open SharePoint Designer 2007, and browse to the document library. Open the page you have just viewed (Forms\Allitems.aspx).
- In design mode, right click on the document library web part (List View Web Part) and click on "Convert to XSLT view".
- Save the page, and open it in browser.
- Click on one of the items again. This time the file won't open, giving you 400 error.
Cause:
This bug is happening because the URL of the file is now encoded, converting apostrophe chars to this: '. This encoding format is good for HTML and not for URL.
To prove this, try to replace the ' part of the URL with the original apostrophe char.
See how the document is opening without any problems?
Solution:
Modify the XSLT that SharePoint Designer generates, and use the {@ServerUrl} instead of the {@FileRef} attribute.
- Open SharePoint Designer 2007 and navigate to the page containing the Data Form Web Part. (follow the "Steps to Reproduce" above)
- In Code view,search for the following peace of code:
HREF="{@FileRef}" - Replace it with the following peace of code:
HREF="{@ServerUrl}" - Save the page.
* ServerUrl does not encode apostrophe at all.If you want, you can still encode apostrophe chars (in the URL format encoding) - Use {@EncodedAbsUrl}, or manually encode the string using XSLT or Javascript.
That's it, now browse again to that page you have just modified, and see for yourself - Opening a file with apostrophe in it's name actually works.
Update: After writing this, I found out that there are detailed instructions for this in the official documentation that you can download from telerik's site. HOWEVER, I haven't found anything online when I searched for the first time, so I decided to publish it even so.
I have written before about rad Editor for MOSS, and how great it is. When you install it, you can add the new rad Editor Web Parts instead of the usual Content Editor Web Parts, and also replace the default content editing control for list items, with rad's control.
What you can't do, is automatically replace the Field Controls in MOSS's publishing layout pages with rad's control.
You can however manually edit your layout pages, and make the replacement yourself.
Here is an article that explain how to accomplish this task: http://www.telerik.com/help/aspnet-ajax/using-radeditor-in-web-content-management-scenario.html
This article is referring the full version of rad Editor for MOSS, and not the Lite (and free) version.
If you use Lite version, just follow the article, and when you reach step 2 of Using SharePoint Designer section (as below)
Change the version attribute to Lite's version. The current version for Rad Editor for MOSS Lite is 4.5.3.0, so the line will look like this:
<%@ Register TagPrefix="telerik" Namespace="Telerik.SharePoint.FieldEditor" Assembly="RadEditorSharePoint, Version=4.5.3.0, culture=neutral, PublicKeyToken=1f131a624888eeed" %>
Continue with the rest of the article as is.
PS: If you are using the full commercial version of rad Editor for MOSS, you have this as a new feature in the latest version.
A new update is available for your SharePoint farm!
The updates mainly applies to tow of MOSS's features: Search, and Content Deployment. (The Infrastructure Update has more to offer for other Office products, but for us SharePoint guys those I listed are the relevant ones.)
Search
Earlier this year Microsoft has released a new product called Microsoft Search Server 2008. This product was the successor of MOSS for Search and provided with an extensive search solution for the enterprise. Based on MOSS 2007, MSS 2008 featured some improvements that was promised to arrive for MOSS also, in the second half of 2008. This new infrastructure update is actually the delivering of that old promise. (More Info here: http://blogs.microsoft.co.il/blogs/itaysk/archive/2008/03/04/microsoft-search-roadmap.aspx)
The new search related features are:
Content Deployment
MOSS 2007 provided an out of the box tool for deploying content called Content Deployment. From my experience with many different MOSS farms, This tool was not 100% functional in the reality test.
The infrastructure update includes bug fixed for this tool, and maybe put it back into the spotlights.
More info: http://blogs.msdn.com/ecm/archive/2008/07/15/content-deployment-and-the-infrastructure-update.aspx
Update: There a hotfix that automates this fix: http://blogs.microsoft.co.il/blogs/itaysk/archive/2008/11/18/sharepoint-designer-data-form-web-part-context-menu-bug-part-3.aspx
In one of my last posts I wrote about a bug that we found in SharePoint Designer's 2007 Data Form Web Part (DFWP), and how to fix it. (Look at the original post for a detailed description of the bug)
Microsoft Support guys has read that post and provided an additional tip for permanently fixing that bug. They have also confirmed my solution is correct.
Tough the fix that I suggested works great on existing DFWPs, here is how to prevent it from happening again:
- Go to the folder where SharePoint Designer 2007 is installed. Usually it will be: "c:\Program Files\Microsoft Office\Office12".
- Find the file CAML2XSL.XSL and open it in a text editor (I used Notepad).
- Look for the following peace of code (There should be only one occurrence of it) :
ddwrt:CurrentRights()
- Replace it with the following peace of code:
@PermMask
- Save the file.
That's it. The next time you will "Convert to XSLT Data View" context ,menus will be working as expected.