Logo 
Search:

MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

SharePoint 2007 - custom view filter issue

  Date: Oct 13    Category: MOSS    Views: 841

I have to created a custom view in code which will be filtered on Date is
Equal/Greater than today's date.

This is my query
string dt = "[Today]"
string query = "<Where><Geq><FieldRef Name=\"HolidayDate\"/>" +
"<Value Type=\"DateTime\">" + dt + "</Value></Geq></Where>";


This runs fine, and I can see the filter properly set up in the UI. But this
does not work.

It only works if I edit the view and just click Save without doing anything.

string dt = "Today" , works but then it writes the filter value as today's date
not as dynamic field.

If I create a filter which is not based on dynamic value, that it works without
problem.
The dynamic [Today], requires me to save it again and then Moss applies the
filter

Please advise

Here is the complete code

StringCollection viewFields = new StringCollection();
viewFields.Add("Title");
viewFields.Add("Date");

const string orderByColumn = "FileLeafRef";
string tName = "[Today]";
// string dateT =
Microsoft.SharePoint.Utilities.SPUtility.CreateISO8601DateTimeFromSystemDateTime\
(DateTime.Today.AddDays(1));

string query = "<Where><Geq><FieldRef Name=\"Date\"/>" +
"<Value Type=\"DateTime\">" + dateT + "</Value></Geq></Where>";


// here you can filter your items using the selected item in the
dropdownlist
oViewCollection.Add(strViewName, viewFields, query, 100, true,
isDefault);

oWeb.Update();
oList.Update();

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on SharePoint 2007 - custom view filter issue Or get search suggestion and latest updates.




Tagged: