Showing posts with label CAML. Show all posts
Showing posts with label CAML. Show all posts

Thursday, July 3, 2008

Creating a view for birthday


Well, I struggled with this for an hour or so until I finally found a solution...

Scenario:
our customer has a list of users with a date field with their Birthday.
He wishes to see the upcoming birthdays for users in the upcoming week.

Problem:
The birthdate field holds the actual birthday of the user (i.e. July 24 1980), but he wants to see it as July 24 2008... July 24 2009... and so on.

Well, since we cannot use the [Today] field in calculated column (all tricks wont work - the field won't update!), I have conjured this solution that only asks for a yearly update to the column:

First, we have to create a calculated column that results in the current year birthdate
(from July 24 1980 to July 24 2008)

1 - create a date column to hold real birthday (named: BDay) or type date.
2 - create a calculate column to hold this year's BDay (named: YBDay).
3 - set the output type of the calculated value to "Date and Time"
4 - use this formula to generate its value:
=DATE(2008,MONTH(BDay),DAY(BDay))


Now, the rest is easy:
You create a view and set filter to 2 conditions:
where [this year birthday] >= [Today]
And
where [this year birthday] <= [Today] + 7


Now, you see all birthdays for the upcoming week!

Just remember - next year you will have to update the formula of the calculated field.

Hope this helps you - sure did saved me :)

Monday, May 7, 2007

Adding a new content query report

Many of my customers are experiencing problems during the creation process of their publishing portals in MOSS 2007 WCM enabled sites.
The two main issues I found are not having an easy way to check-in and publish/approve all pages we developed at once (very much needed when building a new site) and the ability to view all checked out documents in my site collection – just so we could know where we stand in our publishing process.
For the first problem I had to write a nice utility (I will try to publish it for free soon… promise! When finished it will be available here: http://www.kwizcom.com/ – look for the free stuff), but for the second issue I found a simple solution that asked for no more than few seconds of "hard labor" to solve.
(by that I mean some googling was needed)
Well, you might of noticed content editing enabled sites have some reports in their site settings menu:



Clicking one of these menu items will bring you to the manage content and structure page, where a search will be performed on all items according to the report you wanted.



Now, adding a new report to this list turned out to be really easy. All I had to do is click the "content and structure reports" list under the root site and there I found all queries there with their CAML code!


So – to add a new search that will show all items that are checked out to any user simply add a new item there and set this as the CAML for the item:
<where><isnotnull><fieldref lookupid="TRUE" name="CheckoutUser"></isnotnull></where>
Now, this is not perfect yet, you could limit this query to lists/libraries etc… but hey – I have to leave something for you guys to write about, no?
Hope this helps some of you guys, don’t forget to vote!







Shai Ben Shooshan
shai@kwizcom.com
KWizCom Canada