Sharepoint lead is a place where you can read about interesting topics related to sharepoint, and you can also post comments and suggessions.

Sunday, December 30, 2012

SharePoint 2010 foundation on windows 7

If you are planning to install SharePoint 2010 foundation in your windows 7 machine, there are very good references out there in many blogs. But after I installed it I was not able to create new web applications.

I noticed, I was an administrator account with different name than administrator. I found here that we can enable in built administrator account.

I enabled administrator account and added it to managed accounts and farm administrators group.

After trying so many things from forums, finally I got everything working in SharePoint Foundation in my machine!

Friday, December 28, 2012

SharePoint 2013 FBA Pack

I tried to install SharePoint 2010 FBA Pack in SharePoint 2013 and it was working almost OK. I started facing some minor issues and I fixed them one by one.

Entire solution with my fixes is available as a BitBucket repository here

Following are list of issues and how I fixed them.

  1. When you go to add new user from user manager, and click on cancel, it was showing error
    Replaced code
    string url = "FBA/Management/UsersDisp.aspx";
                SPUtility.DetermineRedirectUrl(url,SPRedirectFlags.RelativeToLayoutsPage, this.Context,null, out url);
    string url = "/_layouts/FBA/Management/UsersDisp.aspx";
                //SPUtility.DetermineRedirectUrl(url,SPRedirectFlags.RelativeToLayoutsPage, this.Context,null, out url);
    So, in nutshell, when you are using the previous code, it redirects to /_layouts/15/FBA/UserDisp.aspx and our actual path is in 14 folder.
  2. Similar redirection problems where there when you click edit user and click on cancel, click on reset password and click on cancel etc. I fixed them all by replacing SPUtility.Redirect to Response.Redirect
  3. Use of upgraded user controls.
    When you go to any page, for example UserNew.aspx, you will notice that there are controls used in the page that are registered from "_controltemplates/xxxx.ascx", I upgraded them to use "_controltemplates/15/xxxx.ascx.
    You must be wondering how did I come to know about this? I looked at the page in 15 hive's admin folder and some random aspx page over there, I noticed the new path.
  4. Last one was, Due to SharePoint 2013 titles, breadcrumbs where causing long scroll. I updated resource file to update titles. I just updated titles and used "Manage Users", "Add Users" in place of using all long titles that are used out of the box.
  5. When I tried to package the solution after changes are done, It was giving me too long path error, so I renamed project name and package name to FBA. You will still able to install/upgrade it using stsadmin command.
This are really simple and small fixes, and only contains minor changes that make you able to work. If you have any other bugs, just post it to the public BitBucket repository that I have created and I will try to help you.

In next couple of posts we will discuss about adding customer properties through profile provider. If you have any other sugessions or feedback, I will be more than happy to hear back.

Wednesday, July 4, 2012

Not able to change page layout

Due to some problem in page, Page Layout button in ribbon is showing disabled.
Use following as QUICK solution if you are creating a new page:
  1. Delete newly created page
  2. Go to site settings > Page Layouts and Templates
  3. Locate "New page defualt settings" and select the page layout that you want to set as default page layout.
  4. Save setting
  5. Create new page
There can be many reasons of Page Laout showing disabled in ribbon. You can reference following links to go deeper and resolve it properly.
  1. Try check out the page and then go to edit mode of the page.
  2. Try different browsers to change page layout
  3. ​Change page layout using powershell
  4. Reference link 1​

Monday, July 2, 2012

SMTP4DEV: Your sharepoint 2010 out going email server for development farm

If you are having standalone sharepoint 2010 development farm on window7 64bit, and looking for good option,  SMTP4DEV. It is a free tool. You will need around 10mins and then you can start receiving emails from sharepoint farm! Here are quick steps:

  1. Download  SMTP4DEV from it's codeplex project site, I prefer standalone exe but you can download installer as well.
  2. If you like to use some custom local domain, click on options and set up some local domain like local.machinename.com. Create host entry pointing to
  3. By completing these many steps you can now send emails through  SMTP4DEV by any url ending in @local.machinename.com
  4. Go to sharepoint central administration > System settings > setup outgoing email server.
  5. set local.machinename.com as server, and provide any email ending in @local.machinename.com 
  6. Save your settings
After these minimum set of configuration you will be able to start sending emails. Beauty of SMTP4DEV is:
  1. It will show you notification that new email is sent
  2. It will show you all emails sent from the smtp in UI without actually sending it
  3. You can inspect email
  4. You can view email (in email client that you set default)
So, in conclusion, it is a best choice KISS kind of solution for your sharepoint 2010 development farm's outgoing SMTP server.

Sharepoint 2010: TryGetList vs GetList

As a developer, you will say GetList can throw exception but TryGetList will not. It is actually confusing because TryGetList looks for listTitle and returns null if list is not available at expected location. GetList will expect listUrl and can throw FileNotFoundException or ArgumentException if list is not present at expected location or relative/absolute url of list is invalid relatively. Another biggest difference is they belong to different class!

Apart from all those technical details, I noticed that many sharepoint administrators likes to start with a simple list/library name and eventually change it to make it as close as possible to what they do. That will make list/library url and their names different. Here comes the actual problem. If you are actually using list/library names in your code, it will no longer work. OR we can say you are not allowing sharepoint administrators to change name of list/library that they have created. 

By using GetList you are actually giving them flexibility to use whatever name they like to use, as far as they are not changing url or list/library code will still work.

In conclusion, it really depends on requirements how you are going to deal with the situation but it is good to keep in mind that you can use GetUrl function in your code to allow sharepoint administrators to change their names without worrying about breaking functionality.

Friday, June 22, 2012

How to use soapUI to review ListData.svc


​SoapUI is a free tool that can be used to test out of the box ListData.svc service provided by sharepoint. This service is available at /_vti_bin/ListData.svc for any of your sharepoint site. Here is how we can try it out using SoapUI.

Step 1: Install sopa UI and click on File > New SoapUI Project. Add some project name and check "Add REST Seervice:" like shown in following figure and then click OK

Step 2: After clicking on OK another window will open like following, just click on OK

Step3: New REST resource window will appear. In resource name enter site url and in resource path/endpoint provide list/document library name and click on "Extract params" button. Following is the screen that shows sample data.

Step4:That will automatically create a new request called Request 1.This request will automaticlaly detect endpoint and path to your list/document library. If it is not, just click on"-no endpoint set-" and click on add new endpoint. Enter site url in the dialog again.

Step5: Maximize "Request 1" window in soapUI. In botton left corner you will see " ... ", click on it and you will be able to provide sharepoint authentication details there.

Step6: Once you are done with authentication details you can click on execute icon at top left corner of "request 1" window (marked in above figure) to execute the request and you will be able to see response at right hand side window.

Step7: ListData.svc can also return json data in response out of the box. Just try to provide accept = application/json like shown in figure below:

SoapUI is a super simple too to try out and it will be really help to review xml/json data while you are planninig to consume it with jQuery. 

Monday, May 28, 2012

CAML Designer: Try it now!

When you want to design/test your caml query, most of the time uses U2U CAML Query builder. Sometimes you get problem with connection but most of the time, it was working fine for most of the needs.

Recently, I tried CAML Designer which is really nice tool to try as alternative. WPF UI experience with many additional features may impress you to switch to this new tool.

Let me know your experience while evaluating

Thursday, May 17, 2012

PowerGUI script editor: powershell debugging and intellisense

​​​In this post I am going to show you how to use PowerGUI script editor for executing powershell. There are two main advantages of using PowerGUI:
  1. Dubugging of powershell script
  2. Intellisense support
So, let's start setting up PowerGUI to use with sharepoint 2010:
  1. Download and install latest version of PowerGUI.
  2. Download PowerGUI PowerPack for sharepoint.
  3. Start PowerGUI script editor​ and go to File > Powershell Libraries
  4. Click on "Add Module" and add downloaded "PowerPack for sharepoint" library here
  5. That will add another entry "Microsoft.Sharepoint.PowerShell" into the listing. Check the library to make it enable
  6. Restart PowerGUI script editor and you are ready to get started.

Wednesday, May 16, 2012

Best Practice: Maintaining scripts in your sharepoint project


Branding is the most important part of any sharepoint project. If you are planning to deliver branding in your release, you have to make sure your developer team is proactive to deliver quality branding from early stage of the project. In most of the branding project, jQuery and javascript becomes must-have part. Here we will discuss practices that can be followed to ensure quality deliverables.

  1. Manage script files
    From the very starting stage of your project, split your all javascript code in three files.
    1. jQuery.min.js - This will contain jQuery reference and should be reference first in order.
    2. jQuery.plugins.js - This should contain all custom plugins we used in it.
    3. ProjectName.js - This hsould contain all your custom code written to get your project pages work properly​​
  2. ​Choosing plugins for your project
    1. Download plugin bundle to your local computer
    2. Generally plugin will contain sample html files, jQuery and plugin script files.
    3. First thing to check is, jQuery version you are using in your project and the one which is used in plugin
    4. If they are different, replace their jQuery.min.js with the one we are using
    5. Properly test the sample provided in plugin in all browsers you are planning to support
    6. Once browser and version compability matches paste plugin's min.js at end of jQuery.plugins.js file.
    7. Implement plugin specific mark up wherever applicable
    8. Always use projectName.js to initialize plugin.
    9. Repeat above process when you choose to add any jQuery plugin
  3. Resolving CONFLICTS!
    Another challenging part is jQuery ready not working or custom plugin you are using is disturbing your site's css. Here are thoughts on the same
    1. Aways use _spBodyOnLoadFunctionNames.Push("yourFunctionName") to init your scripts in page load.
    2. Always use only necessary css from what plugin css has proviced and prefix class or ID in css as application. For example if a generic class .clear is used and you are calling plugin using $('#news') you should replace that with #news .clear. Do this for all css you include for the class

Final thoughts
Here I pointed out some of the best practices. Like this post? You like to add/correct something? please provide your feedback on the same.

SP.UI.ModalDialog.showModalDialog not working in chrome

In some version of browser, using will not work due to some reason. I found an alternate method to solve this problem, here is the javascript code:
var dialogSP = null;
if (SP.UI.ModalDialog.showModalDialog) {
    dialogSP = SP.UI.ModalDialog.showModalDialog(options);
} else {
    dialogSP = SP.UI.ModalDialog.commonModalDialogOpen(countryUrl, options, null, {});

jQuery.find not working in IE7 for xml data

As part of troubleshooting a shareoint functionality, we found that jQuery.find not working.
We were using jQuery.ajax to call a sharepoint web service and in success function, finding an element in response xml to render it on div.
We fixed this and there are couple of options to fix this that we found from stackoverflow.
1. add dataType: 'xml​' in jQuery.ajax and that will fix it.
2. in response, check for browser is IE7 and variable that is having data is blank, do it with another method, here is javascript code:
if ($.browser.msie && liHtml == "") {
    xml = new ActiveXObject("Microsoft.XMLDOM");
    xml.async = false;
    liHtml = $("XmlTagNameToFind",xml).text();
I hope this will he you as well.

Creating web application from existing content database

There are situations where you want to propagate one SharePoint web application to some other farm/machine.   I feel the fastest way is to take content database backup and restore it in your destination farm. I have done so in last couple of weeks and I have leaned how to quickly do that.
Here are quick notes from my experience:
I was provided with content database backup and source code. That makes be able to restore site and generate wsps from source code.
Creating  content database from backup:
Go to your database server and do following:
  • Create a blank database that will be used as content database 
  • Restore a database using content database back up from source farm.
Creating a web application:
  • Go to sharepoint central administration and create a new web application
  • While creating a new web application, use existing content database in database section
  • Sometimes if your database is too large, web application creation takes too long and times out. Don't worry at all. web application is still created successfully. It happened to me 4 times out of 5. 
Validating the web application:
  • Go to sharepoint central administration, click on application management. In "Databases" section you will find "Manage content databases"
  • Choose your application and it will show database status and number of site collections. If you are not sure how many site collections are there in backup, anything greater than 0 is good news.
Configure web application to work properly:
we are almost done now. Do following:
  • Go to sharepoint central administration
  • Click on "Application Management"
  • In "Site Collections" section click on "Change site collection administrators"
  • choose your web application set proper data in site admins.
Additional optional steps:
After performing all the above steps, it is still possible that you are not able to access your web application.
  • Last thing to do is to install and deploy wsp by using stsadm or your favorite method. 
It is always challenging to move applications from one farm to another. Specially when they are depending upon other service applications. In spent last two weeks to learn how to properly do that. I hope this will help you at some point during your sharepoint development.

stsadmin -o deploysolution shows access denied error for some files


After firing deploysolution, looking at system settings > farm solutions and the error looks something like "Can not overrite xxxx file, access is denied".


specified file in your error is read only in your web application directory. Most of the time this happens when you are using some source control system that is making the file read only when it is checked in. 


Go to properties of the file and uncheck read only. If you are running a farm and you got multiple application servers, you need to repeate this for each application server.


80% of the developers uses command line to deploy their wsp as it is the convinient way to add or upgraded the solution.


Got the same error? Don't worry try above solution. Didn't worked? Let me know which one worked for you?

Monday, May 14, 2012

using HttpContext.GetGlobalResourceObject in webpart development

I found interesting issue during working with global resource files this week.

Event if we are using HttpContext.GetGlobalResourceObject, web part was rendering data in English even if site language is other than English!

If we switch to edit mode, it was working sometime, but most of the time it was showing English text.

Root cause:
We tried creating a new application page and placed a webpart there, it was strange that it was working properly in the application page.

We finally found that at the time of reading resources through  HttpContext.GetGlobalResourceObject web part was not aware of the current UICulture

   1:  var strLinkText = HttpContext.GetGlobalResourceObject("file", "key");
   1:  var strLinkText = HttpContext.GetGlobalResourceObject("file", "key",SPContext.Current.Web.UICulture);

Finally after passing third argument from SPContext.Current.Web.UICulture it worked properly