Navigation Bar

Saturday 21 July 2012

Installing SharePoint 2013 Preview

I have tried installing SharePoint 2013 Preview on VirtualBox and kept failing on Configuration wizard.

Run following through powershell
PS C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\BIN>
 .\PSCONFIG.EXE -cmd Configdb create SkipRegisterAsDistributedCacheHost

Once you have ran above command re-run Configuration wizard. You may get an exception in step 8 (i.e failed to create sample data...). Ignore this exception as Central Admin has been provisioned.
You can find detail post from here: http://tomblog.insomniacminds.com/2012/07/17/sharepoint-2013-standalone-installation-issue/

Thanks for reading my post.

Tuesday 10 July 2012

Calculated columns in SharePoint

One of the cool field type is the Calculated field. That is used to do some custom calculation or performing some logic based on existing field.

I used calculated field in one of the project that was based on SharePoint workflow and had some logic to kick of workflow. It was late 2 years back and that time I was not blogging. Recently I created couple of Calculated columns so I decided to blog it so that I can and my SharePoint felows can get benefit now and in future as well.

Calculated field works like Excel cell. For instance we want to calculate the next schedule/review date based after 60 days of the date supplied.

The formula for above scenario is very simple:

Next review date: [Review Date] + 60

Similarly if you want to show "First Name" + "Last Name" as Name in the list, just use below simple formula:

Name: [First Name] + " " + [Last Name]

We can also use IF ELSE in the formula. For instance if you need to calculate schedule/review date based on type of document. If document type is Urgent, then review should happen in 10 days otherwise in 30 days.

Next review date: =IF([Document Type]="Urgent", [Review Date]+10, [Review Date]+30)
Where [Document Type] is choice field, and 'Next review date' is calculated field type.

Remember, the fiels must be closed with [ and ] brackets.

Whenever I need to use formula in Calculated field, I open my excel and create a formula and use it in SharePoint.

For further reference please visit http://office.microsoft.com/en-us/windows-sharepoint-services-help/examples-of-common-formulas-HA001160947.aspx

Saturday 7 July 2012

Learning SharePoint from SharePoint

Last week I was so busy with my family so I could not get time to write anything. Luckily I have got some time this week.

To learn anything you would need some tools related to what you are going to learn, perhaps some books or some software etc.
For SharePoint we need following things:
1.       SharePoint environment offcourse
2.       A tool to decompile the SharePoint dll code (dotPeek or Reflector)
3.       Items you want to learn (For instances Site Template, Features, Layout Pages etc)

You can find everything related to SharePoint in 12/14 hive. Let’s get started!
Below is the snapshot of 14 hives (as I am using SharePoint 2010)


If you want to deploy your own custom WCF or ASMX web service, ISAP is the recommended place to use it. When you deploy in 14 hives it is recommended that you should use your own folder.

WebService / WCF Service Deployment Scenario
Let’s say I want to deploy a WCF that creates an Order and save it to SharePoint list/or database.

So folder structure would be:
14 hives \ ISAPI \ CompanyName \ ProjectName \ CreateOrder.svc

When you reference you would be referencing with http://SharePointSiteUrl/_vti_bin/CompanyName/ProjectName/CreateOrder.svc

Also you can get the url from IIS. Go to your IIS as shown below and select the CreateOrder.svc page and right click and click Browse option.




Application Pages deployment scenario


If you want to deploy your own custom application page, you should deploy all your custom application pages to 14 hives\TEMPLATE\LAYOUTS\CompanyName\ProjectName\YourCustomPage.aspx

SharePoint Resources (Images/CSS/JS) scenario

Images should go to:
14 hives\TEMPLATE\LAYOUTS\1033\Images\CompanyName\ProjectName\your images

CSS should go to:
14 hives\TEMPLATE\LAYOUTS\1033\STYLES\CompanyName\ProjectName\your css

Javascript files should go to:
14 hives\TEMPLATE\LAYOUTS\1033\ CompanyName\ProjectName\javascript files

Creating Site Template scenario

Browse 14 hives\TEMPLATE\Site Templates and pick the easiest one that is sts and inspect the folder structure and files. If you observe the structure then it will be easy for you to create a custom site template that you can deploy through SharePoint solutions.

All the configuration related to SharePoint template goes to 14 hives\TEMPLATE\1033\XML


Also have a look at xml files located above in the picture. It will tell how to create a configuration and Site Provisioning Provider.

Provisioning a web part to a page using XML declaration

If you open xml located at 14 hives\TEMPLATE\SiteTemplates\sts\xml  or ONET.xml of any SharePoint site template you can see the Module node. Below is a snapshot of Onet.xm file:


If you pay close attention to the red box you will notice that we are saying that we want that web-part (Members webpart) to be added to “Right” zone in that page with order “1”. It means this web-part will be displayed first.

The easiest way to get the xml for web part is to export the web-part from the page and open it to some notepad.

There are lot of things but what I wanted to share is that how you can explore SharePoint yourself.
Some of you guys must be thing where we have used dotPeek or Reflector. J You can use where you want to know how SharePoint is doing some of the stuff. So you can inspect Microsoft.SharePoint.dll or desired dll.

Happy talking about SharePoint !!!

Wednesday 4 July 2012

Customising Search result page through Feature

To customize your search result page, you need to follow below steps; at the end you will end up a .wsp solution that will be used for deployment to deploy your customization to various environments.
I am assuming that you have search centre site. Browse your search result page and modify web parts and supply your changes. For instance in “Search Box” web part you can specify the search result page.
Similarly in “Search core result” webpart you can specify your xsl for the custom layout for the results and if you want additional columns you can specify there as well.




Specify the xsl location not xsl itself. We will be deploying that xsl in _layouts/Masood/demo/customsearchresults.xsl through SharePoint 2010 project as show below.
Once you have done your modifications, it’s time to export those modifications to xml as shown below image:
Perform expert to only modified web parts. For instance we modified “Search Box” and “Search Core Results” web part and save those files.
Now create a SharePoint 2010 project.
Browse 14\TEMPLATE\SiteTemplates\SRCHCEN\XML and open xml file in notepad

 

and search for “<File Url="results.aspx" Type="GhostableInLibrary">”
Copy the contents of above node and paste it your Elements file of “SearchPage” module as show below:

Now open SearchBox.webpart file and copy the xml in clipboard and replace with the contents in <AllUsersWebPart WebPartZoneID="TopZone" WebPartOrder="1"> <![CDATA[ …old contens should be replaced with new
]]> </AllUsersWebPart>


Similarly open SearchCoreResults.webpart file and copy the xml in clipboard and replace with the contents in <AllUsersWebPart WebPartZoneID="BottomZone" WebPartOrder="3"><![CDATA[ old contents should be replaced with new from webpart file

]]> </AllUsersWebPart>


NOTE: make sure you replace the correct xml.  
Compile your project, deploy the .wsp and activate the web-scope feature that will create customsearchresults.aspx search result page with your customization.
There is another way as well … that is totally using C# code in the feature. I will blog it later…stay tuned.
Happy coding!



Sunday 1 July 2012

Debugging SharePoint code in Production


Recently I was asked to troubleshoot production code. Unfortunately we did not have pre-prod or staging environment.

In production, you have to be very careful. You can’t deploy anything without going through some checks (or build pipeline).
Then what I did was very simple thing. Imagine what would have I done!!!
I chose a SharePoint layout page that only displays links. Guess which page it was? Yes it was _layouts\settings.aspx page.
I copied _\layouts\settings.aspx to _layouts\Masood\settings.aspx and modified with my debugging code.
I wrote code in scriptlet.
<%
Response.Write(“Beginning of my debugging code...”);
YourDependencyClass obj = new YourDependencyClass();
obj.SomeMethod();
%>
The other thing I did was I wrote whole classes between< % and %> and fortunately I found the issue. Following is an example

< %
public class YourDependencyClass {
   public void SomeMethod(){
          //your logic…
   }
}%>
I hope that will work for you if you need to do troubleshoot in production environment.