Filtering the sharepoint Content Query webpart
Hi,I wanted to show a published page in sharepoint site using CQWP. I wanted too show only that page which is currently created.What I have done is, i used the CQWP which will filer the page based on today's date.The pages are created in the afternoon.So the problem is ,after midnight the CQWP cannot find a page on the current date and it will return null. So my requirement is that if there is no page in the current date,it should return the previous date page.How can I achieve this.Please help me on this.
February 17th, 2010 10:02am

Hi, If new page not created for current date it will return null fields only. try to change the filter option for offset days <![CDATA[ <Where> <Gt> <FieldRef Name="Created" Nullable="True" Type="DateTime"/> <Value Type="DateTime"><Today OffsetDays="-7"/></Value> </Gt> </Where> <OrderBy> <FieldRef Name="Created" Nullable="True" Type="DateTime" Ascending="FALSE"/> </OrderBy> </Query>]]> Refer msdn link http://msdn.microsoft.com/en-us/library/aa981241.aspx Thanks,
Free Windows Admin Tool Kit Click here and download it now
February 17th, 2010 10:23am

Can we do it using the default CQWP available in sharepoint or should we go for custom webpart?
February 17th, 2010 10:27am

You can use default CQWP
Free Windows Admin Tool Kit Click here and download it now
February 17th, 2010 1:00pm

Could you please tell me how to do it? I cannot find an option to write the query in the default CQWP.Please help
February 17th, 2010 1:09pm

I made this change in the default CQWP.(I exported it to my desktop, opened in notepad and made the change u mentioned above in the <property name="QueryOverride" type="string"> <![CDATA[ <Where> <Gt> <FieldRef Name="Created" Nullable="True" Type="DateTime"/> <Value Type="DateTime"><Today OffsetDays="-7"/></Value> </Gt> </Where> <OrderBy> <FieldRef Name="Created" Nullable="True" Type="DateTime" Ascending="FALSE"/> </OrderBy> </Query>]]> But when I import this to the site. , it is throwing error "There is a problem with the query that this Web Part is issuing. Check the configuration of this Web Part and try again."Please help me with the query.
Free Windows Admin Tool Kit Click here and download it now
February 18th, 2010 10:13am

Hi, Refer this msdn article http://msdn.microsoft.com/en-us/library/aa981241.aspx also look up Heather solomon article http://blogs.msdn.com/ecm/archive/2006/10/25/configuring-and-customizing-the-content-query-web-part.aspx Thanks,
February 18th, 2010 1:00pm

Hi,i get it correctly when I give it as Today alone.So the issue is with query. i need a query which returns page created with today's date if available otherwise page created with yesterdays date if page with today's date is not available.Please help.
Free Windows Admin Tool Kit Click here and download it now
February 18th, 2010 1:09pm

Hi, Use <or> Query http://msdn.microsoft.com/en-us/library/ms472196.aspx Write two conditions inside where query 1) check Current date and 2) check current date -2 or current date -7 Thanks,
February 18th, 2010 1:42pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics