Friday, September 7, 2012

CSS and Javascript tips

I learned 2 interesting things today.

1. After you apply custom style sheet to your content in SharePoint, it is still not getting applied when you check in browser. The reason for that is the SharePoint overrides your style (css class). To over come this situation, you can declare your styles in css class as !important. This lets SharePoint know that your css class is priority.

    font-family: Arial !important;
    font-size: 9pt !important;

2. If you want to execute javascript code after successful validation of controls (required field validator etc...) you need to write a small javascript function which calls Page_ClientValidate to fire validation and get its status (successful - true; unsuccessful-false).

and here is the button markup...

Happy Coding
Vighnesh Bendre

Tuesday, August 21, 2012

SharePoint 2013 (SP 15) - Creating Custom Lists

As I am exploring SharePoint 2013, I found out that there are lot of things that are new and there are lot of thing that are old but presented in a different manner as compared to SharePoint 2010. For example, Site Actions was on the top left corner in SP 2010. But in SP 15 (SharePoint 2013) we dont have ‘Site Actions’ button. But instead we have a settings icon which is placed at top right corner.

When you click on the settings icon select Add an App. This will basically allow you to add custom lists, documents libraries etc. Add an App is basically the same as More Options in SharePoint 2010. From now on custom lists & libraries will be called apps. Just like in Apple store or Android store you can develop apps for SharePoint and sell it. You can find more information here:

When you click on Add an App you will be navigated to a different scree which will display different options like, Document Library, Custom list, Form Library, Wiki Page Library Picture Library etc. In SharePoint 2010 when we click ‘More Options’ in Site Actions there will be a AJAX popup which displays options where we can select and create doc lib or custom list or site etc. I found that to be more easy to use than navigating to new page alltogether.

Now when you click on Custom List. You will get a popup which asks for name of the list.

Once you provide name and hit Create a new custom list is created. As expected a new blank custom list is created with one column – Title. Top of the list has a link to add new item. There is a ‘edit’ link to edit list data in data sheet view. You will also notice that there is a search box which will help you in finding an item in the list. We had filter web parts to achieve this earlier.

One more thing I noticed in ribbon is the navigation of items. In Manage Views category you can see a small box which says 1-30. From here you can navigate easily instead of scrolling down to the screen to see next/previous buttons which was the case in SharePoint 2010.

These are the couple of things I found interesting. I would have liked to see add an app to be in the popup instead of navigating to different page.

Changing Theme
Another opting you will see on the home screen is of changing themes. It is fairly easy to use and change theme of your site. When you click on changing theme you will be navigated to a page which displays different options. You can choose from these options. If you like the theme you can apply it or discard the same.

I will be exploring more about SP 15 in coming days. 

-Vighnesh Bendre

Thursday, August 16, 2012

SharePoint 2013 First Look

Finally I have installed Windows Server 2012 Full Server (8400.0.WINMAIN_WIN8RC.120518-1423_X64FRE_SERVER_EN-US-HRC_SSS_X64FRE_EN-US_DV5.ISO). I have installed it on Oracle Virtual Box. In my previous blog I have explained how I was struggling with installing Server 2012 on VMWare first. And then when I was successful in installing it on Virtual Box, I had actually installed server core version of Windows Server 2012. 

This time around, I downloaded the full server version of Server 2012. I was able to proceed with installation without any hiccups. 

While creating the VM (using virtual box) I had faced some issue with hard disk space allocation. I have explained it in another blog here.

Let us start with the new and improved UI of SharePoint 15. This is how the UI looks like. It follows the new metro look.

There are lot of new things. And old things put in new place on the screen.

  1. The famous Ribbon of SharePoint 2010 still exists and placed in a different line. I also noticed Windows Server 2012 also implements ribbon concept. If you see windows explorer, that also has ribbon on top.
  2. Information about the person who has logged in is displayed in the top right corner. Site Actions has become just a image. And when you hover on top if it, it shows “Settings”. You also have Help and Feedback icons in this section.
  3. In this section, you have “Share”, “Follow”, “Synchronize”, “Edit” and “Focus on Content”. For Share, you will get an popup like below where you can enter user names and share the page with them.

When I clicked “Follow, I received below error. I am getting these kind of errors in a lot of places. I am sure MS is fixing these.

“Sync”will allow you to sync data with workspace which is a desktop application. “Edit” will allow you to edit the current page. There is another new option “Focus on content”. Which when clicked will show only the content without the left navigation. You will still see the top part of the page. I like this option as lot of our users lose the screen space when we add left navigation. 
4.  Logo image. Nothing new here.
5. In left navigation, apart from normal behaviour we have “Edit Links” with which you can edit links in the left navigation. This allows you to add/update/remove links.

6. Get Started with your site shows some quick links.
7. This section shows Documents library. A good feature here is that you can directly drag and drop documents on the web part.  

All in all, there are some cool new features added in the UI. This is the first impression of SharePoint 2013 or SP 15. There is more to come. Keep watching.

-Vighnesh Bendre.

Oracle Virtual Box – Increasing Allocated Disk Space


For working with Windows Server 2012 & SharePoint 2013 this time I choose Oracle Virtual Box. Microsoft has recommended 60GB of harddisk space for running Windows Server 2012 and SharePoint 2013. When creating new virtual machine (VM) the Vbox took 25 GB as the default for hard disk space. It also mentioned that it is dynamic allocation. I guessed that this will increase as and when the VM needs more space. 

I was wrong. I created new VM and installed Server 2012 successfully. But when I was installing SharePoint 2013 the istallation did not succeed because of less disk space. 

After some googling, I found a command (run from command prompt) to increase disk apace allocated to the VM. Below are the steps for the same.

  1. Open command prompt on host system.
  2. Navigate to C:\Program Files\Oracle\VirtualBox.
  3. Execute below command: VBoxManage modifyhd filename.vdi --resize 61440
  4. Above command will increse the allocated disk space to 60 GB.
  5. After running this command, I was still not able to see change in the VM. So in the VM I went to Server Manager. Click on “File and Storage Services”.
  6. Now click on “Disks”

 7. Right click on C: in Volumes section and click on Extend Volume.

8. Now enter the New Size and click OK.

After these steps, I was able to proceed with SharePoint 2013 installation. Hope this helps people who are working on Virtual Box. 

-Vighnesh Bendre


Wednesday, August 8, 2012

Installing Windows Server 2012 for SharePoint 2013

I follow Corey Roth’s blogs. In his blogs he has given so much information regarding SharePoint 2013 that I got inspired and started my journey of learning SharePoint 2013.

My first task was to get SharePoint 2013 installed on my laptop. I have Intel i5 2.4 GHz (2) with 8 gig memory. I am running on Windows 7 Professional 64bit. I already have VMWare (8.0.4 build-744019) installed where I do my development on Windows server 2008 R2 with SharePoint 2010. So my obvious choice was to get SharePoint 2013 image and install it on my already running VMWare Server 2008 R2. I downloaded the 2.1 gig image and tried installing it on my VM. But failed. There were varied reasons for the failure.

So I decided to get Windows Server 2012 and create a new VM from it and then install SharePoint 2013 on it. I downloaded the Server 2012 Hyper-V Release Candidate (8400.0.WINMAIN_WIN8RC.120518-1423_X64FRE_SERVERHYPERCORE_EN-US-HRC_SHV_X64FRE_EN-US_DV5.ISO). Then tried to create a fresh new VM from VMWare. 
But during installation, when the server restarts for the first time, the system would get hung. It would not proceed further. No errors. Just the black screen with the hung rotating image. I tried to do the installation twice. No luck.

But then I saw another blog post from Shail here:  Where he has provided step by step guide to install Server 2012. But in his blog he has used VirtualBox. So I also decided to install VirtualBox and try my luck. This time I was able to complete the installation successfully.

But after login screen, I get only command prompt. No UI. My colleague IT admin Mr Ganesh said that while installing (setting up) I have chosen Server Core and not Full Server installation. But I remember clearly that I did not get any such choice while installing the server.

Then we both started googling how to switch between command prompt to GUI (full server installation). I got lot of options, lot of trial and errors. But nothing worked. Below are some of the steps I tried out…

Step 1: To use Windows PowerShell to convert from a Server Core installation to a Server with a GUI installation (
  1. Create a folder to mount a Windows Imaging File (WIM) in with the command mkdir c:\mountdir
  2. Determine the index number for a Server with a GUI image (for example, SERVERDATACENTER, not SERVERDATACENTERCORE) using this command at an elevated command prompt: Dism /get-wiminfo /wimfile::sources\install.wim
  3. Mount the WIM file using this command at an elevated command prompt: Dism /mount-wim /WimFile::\sources\install.wim /Index:<#_from_step_2> /MountDir:c:\mountdir /readonly
  4. Start Windows PowerShell and run this cmdlet: Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell –Restart –Source c:\mountdir\windows\winsxs
  5. Alternatively, if you want to use Windows Update as the source instead of a WIM file, use this Windows PowerShell cmdlet: Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell –Restart
  1. Dism /online /enable-feature /featurename:ServerCore-FullServer /source:d:\sources\sxs
  2. Add-WindowsFeature Server-Gui-Shell

With unsuccessful attempts, I decided to download Server 2012 RC (no Hyper-V this time) and install it on VirtualBox. 
I will update in my next post about my findings…

Happy SharePointing (2013)
Vighnesh Bendre

Monday, April 16, 2012

Another Reason for 'Group can not be found' error in SharePoint 2010

Recently I was working on an workflow where I was accessing a group from SharePoint 2010 and from there trying to get user's mail ids. I created a group in SharePoint 2010 from UI. Since this group was supposed to hold only users (approvers for workflow), I did not assign any permission to the group. I left all the check boxes unchecked.

Next when you try to get the group from code in workflow, you will get error saying 'Group can not be found'. Below is the code I had written in my VS 2010 workflow.

SPGroup spgApprovers = workflowProperties.Site.RootWeb.Groups["Some Group"];

After some googling, I found that if you have not assigned any permission to the group, it will not show up in the code. So I went back to the group, deleted it and recreated with reader permission.

Hope this will help someone...
Happy SharePointing...

-Vighnesh Bendre

Friday, April 13, 2012

Validation before Save in New or Edit form

If you want to do validation based on other column in your out of the box New or Edit form, you can do it using JQuery in SharePoint 2010.

In the code below I am trying to validate a text column if the value in the status drop down list is ‘In Process’.

The function PreSaveAction() gets fired when the user clicks on ‘Save’ button in the New or Edit form. In this function you can create object of the drop down list and text control and check if the text control is empty when the status is ‘In Process’.

function PreSaveAction()
   var selectedVal = $("select[title='Status']").find('option:selected').text();
   if(selectedVal == 'In Process')
       var chrgtoNum = $("input[title='SID Number']").val();
       if(chrgtoNum == '')
          alert('Please enter SID Number.');
          return false;
       else{return true;}
   else {return true;}

You can see my other blog to learn how to put this code in New and Edit form.
Validation or control form from JQuery - Default New and Edit forms

Happy SharePointing...


Validation or control form from JQuery - Default New and Edit forms

When you create a custom list, you get default edit and new forms with it. So when you are entering data or modifying it SharePoint provides you a form in a popup that enables you to enter or modify data.

But then, if you want to add custom features to the new or edit form, you can do so using JQuery. In the below example, based on the valued selected in the dropdown list, I want to enable or disable other control. And I want to add this JQuery code to the New and Edit forms of the custom list.

function HideColumn(stat, active) 
        var activeObj = $("input[title='" + active + "']");
       //initially when the user opens the form, we need to check if the user has selected the status that we have written code for…
       //if selected value is other than Suspend, disable the control
        var initialVal = $("select[title='"+ stat +"']").find('option:selected').text();
        if(initialVal == 'Suspend')
        {$(activeObj).attr('disabled', false)}
        {$(activeObj).attr('disabled', true)}

         //Now handle dropdown list’s change event. In this event we will check what is the selected value of the ddl, based on the value, we enable or disable the control…
 $("select[title='"+ stat +"']").change(function() 

  var selectedValue = $("select[title='"+ stat +"']").find('option:selected').text();
         if(selectedValue == 'Suspend') 
              $(activeObj).attr('disabled', false)
  else {
       $(activeObj).attr('disabled', true)

$(document).ready(function() {HideColumn('Status', ' Active');} ); 

In the above example, I have written a function HideColumn which will be called when the document is ready. The parameters to this function are the column names of dropdown list – ‘Status’ and other control which we want to enable/disable.

Now when the user opens the form in edit mode, the status ddl is already selected. At this time, we want to make sure based on the selected value, we change the state (enable/disable) of the other control. In SharePoint you are not aware of the ‘Id’ property of the control. Or this property will be having some junk value. But what you can depend on is the ‘Title’ property. So by passing the title property, we can create the control object.

var activeObj = $("input[title='" + active + "']");

You can get the selected text of the drop down list by using the find method as below.

var initialVal = $("select[title='"+ stat +"']").find('option:selected').text();

Once you are done with enabling and disabling the control at start up, you have to attach change event handler to the status drop down list.

$("select[title='"+ stat +"']").change(function(){});

This function will fire every time you change the value in the drop down list. Now based on the selected value, you can enable or disable the other control.

Now, how do you put this on to the new and edit form? Well go to the list tab, click on ‘Form Web Parts’ and select ‘Default New form’. In the form, click on add web part, click on ‘Media and Content’. Add ‘Content Editor’ web part.

Now in the ‘Editing Tools’ – ‘Format Text’ tab, click on ‘HTML’ – ‘Edit HTML Source’. Paste you JQuery code in this popup dialog. Don’t forget to set the chrome type to ‘None’ in the web part properties.

Follow the same steps to configure JQuery code in the edit form also.

Happy SharePointing...


Wednesday, March 28, 2012

How to find out used storage space by SharePoint list or library

Recently, I encountered a problem where my site's data was growing rapidly. I wanted to find out which list or library is using how much disk space (storage). I found out an easier option to list all the lists/libraries in the site and their corresponding storage space. 

You just have to append "_layouts/storman.aspx" at the end of your site address. But when I checked for the first time, the data was not accurate. But then I saw a message at the top of the page which said data displayed may not be up to date. Revisit the site to get more accurate data. So when I revisited the page. I was able to get accurate information. 

This might help some one...
-Vighnesh Bendre