Monday, January 5, 2009

How Can I Show All Items with/without Folders in SharePoint?

To implement this we have 3 options

Option 1
Using SPQuery object and setting ViewAttributes property in it; You can retrieve only the folders from the SharePoint List, with a single condition.

SPSite site = SPContext.Current.Site;
SPWeb web = SPContext.Current.Web;
SPList list = web.Lists["Shared Documents"];
SPQuery query = new SPQuery();
//Condition to check the item type is folder or not
query.Query = "<Where><Eq><FieldRef Name=’FSObjType’/><Value Type=’Lookup’>1</Value></Eq></Where>";

//Get all the items including subfolders from the list
query.ViewAttributes = “Scope=’RecursiveAll’";
//Retrieve the items based on Query SPListItemCollection items = list.GetItems(query);


string folderDetails="";
//Get the name and Url for the folder
foreach (SPListItem item in items)
{
folderDetails += "Folder Name:" + item.Name + "<br/>Folder URL:" + web.Url + "/" + item.Url + "<br/>";
}

In Query property of SPQuery object, You can set 0 for folder (if item type  = folder) or 1 for List Item/Documents(if ItemType=List Item).

We have set Scope=’RecursiveAll’, which allows to retrieve all the items and folders from the list or library.

Option 2
1. Open Data Source Details pane in Menu > Task Panes > Data Source Details.
2. Click the data source listed in Current Data Source.
3. In the opening Data Source Properties pane, change the item and folder scope from Files Only to Recursive
4. Save and exit.


Option 3
Other than dataview webpart you can also set options directly in views also. To implement this we can take example of "All Documents", follow the steps1. Select "All Documents" view
2. Select "Modify This View"
3. Scroll down whole page
4. Expand Folders
5. Then select "Show all items without folders"
6. Click OK button 

Sunday, December 14, 2008

Microsoft Office SharePoint Server 2007 and Related Technologies pricing

http://office.microsoft.com/en-us/sharepointserver/FX102176831033.aspx

Sharepoint Price Calculator

http://community.bamboosolutions.com/blogs/sharepoint-price-calculator/default.aspx

Saturday, December 6, 2008

Create SharePoint Alerts Programmatically

Using following code you can create alerts

SPUser user = mySite.Users["domain\user"];
SPAlert newAlert = user.Alerts.Add();
newAlert.Title = list.Title;
newAlert.AlertType = SPAlertType.List;
newAlert.List = list;
newAlert.Properties["eventtypeindex"] = "1";
newAlert.AlertFrequency = SPAlertFrequency.Immediate;
newAlert.Update(false);
 
If you want to set an alert for a list, you have to set the AlertType property to SPAlertType.List and set the List property to an instance of the SPList class.
 
If you want to set an alert for a list item, you have to set the AlertType property to SPAlertType.Item and set the Item property to an instance of the SPListItem class, in that your code should be
 
newAlert.AlertType = SPAlertType.Item;
newAlert.Item = item;
 
You can change following codes depending on what action you want to set alert using "eventtypeindex"
 
all = 0
added = 1
modify = 2
deleted = 3
web discussions = 4

If you want to send Alert daily you can change the AlertFrequency as mentioned below

newAlert.AlertFrequency = SPAlertFrequency.Daily;
newAlert.AlertTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 8, 0, 0);

If you are subscribing alerts for some other user, you should be the administrator or should have permisssions to manage alerts thne add your code with following code

SPSecurity.RunWithElevatedPrevilages(delegate()
{

web.AllowUnSafeUpdates=true;
  // Add your code here
});

Friday, October 24, 2008

I am a Microsoft Certified Technology Specialist in MOSS

Today I passed another exam i.e. Microsoft Office SharePoint Server 2007, Application Development exam.






The exam 70-542 were max 80 minutes long and there were 40 questions.
I felt very bad prepared, but I guess that something must had stuck since there were so many lucky guesses :-). I didn’t find it easy at all.

Last time I had a feeling of “knowing the stuff”. This time the feeling was more like “familiar stuff”.