Raghu's SharePoint Corner: October 2011

My blog has moved!

You will be automatically redirected to the new address. If that does not occur, visit
http://www.sharepointcolumn.com
and update your bookmarks.

October 26, 2011

Create List item in Folders using Client Object Model

There are scenarios where you would like to add list item to a folder/sub folder in a custom SharePoint list and many of you would like to achieve this using ECMA script/ JavaScript Client Object Model. Before we start with the code, i am assuming that you have enables Folder Content Types in a custom list and have also created a Folder in a list before the below snippet is executed.


function CreateListItemInFolder()
{

// Create client context
 var myContext = new SP.ClientContext.get_current();
 // Get current web (comparable to SPWeb)
 var myWeb = myContext.get_web();
 // Get list by title (comparable to SPList)
   var myList = myWeb.get_lists().getByTitle('Docs');
   // Create new object for list item creation

 //Create List Item Infor and set the Folder Path for the item to be created.      
      var myListItemCreationInfo = new SP.ListItemCreationInformation();
      myListItemCreationInfo.set_folderUrl("http://servername/sites/PP/Blog/Lists/Docs/Folder1");
 var newLinkItem= myList.addItem(myListItemCreationInfo);

     // Set properties for new list item
 newLinkItem.set_item('Title', "Title");
 // Update the new item
 newLinkItem.update();

myContext.executeQueryAsync(Function.createDelegate(this, onSuccessAddQL),Function.createDelegate(this, onFailureAddQL));

}
function onSuccessAddQL(sender, args)
{
alert("Item Added Successfully In the Folder");
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel,'Closing Quick Links Dialog');
}
function onFailureAddQL(sender, args)
{
alert("Item Adding Failed to the Folder");
}

happy coding..

October 3, 2011

Creating Root Site Collection Using Custom Blog Site Template in Office 365

There are scenarios were you would like to use Blog Template (any default site ) or custom site template as the default site template for the Root Site Collection instead of the regular Team Site In Office 365. By default when you subscribe a new Office 365 Subscription you will have team site as default root site collection.

The steps below will guide you to create the root site collection with a custom blog site template. I have created a site using Blog template and created custom list in the site. After you have the necessity structure for the Blog site in place, save the Site as Site Template and download the Blog Template from the Solution gallery to your local PC.

1. Delete the default root site collection of your subscription, by navigating to the admin portal of Office 365. Your Admin portal looks like the screenshot given below.


2. Now click on the new tab and select New-> Private Site Collection, You will get a new New Site Collection PopUp Screen, specify the title of the site, In the Template Selection, click on the Custom tab and select “Select Template Later”, specify the administrator account and Click OK. The screen should look like below

3. Wait for the site to be created, Once the site is created, Navigate to the site, you will see a Template Selection page were you can select the default template as blog for your root site


4. To use custom blog site template, Click on the Solution Gallery, it will take you to the Solution Gallery, upload the custom Blog Site template WSP and activate. After activating the WSP navigate back to the Template Selection Page and you will be able to see a Custom Tab as shown below, select the BlogSite Template and click Ok

                                    

5. Once the site is created it will navigate you the Set Up Groups for the site Page as shown below and click Ok.

In this way you can use any custom site template or change the default site template for your Office 365 SharePoint Online.