Monday, 18 February 2013

SharePoint 2010 Chart web part raising error

While adding SharePoint web part, its raising error. After surfing google I found solution here 
The blog is showing that I need to Enable State Service in central admin.
Before moving further, I need to tell you that

The State Service is a shared service that is used by some Microsoft SharePoint Server 2010 components to store temporary data across related HTTP requests in a SQL Server database. In SharePoint Server 2010, the State Service is required by InfoPath Forms Services (including out of the box and custom workflow forms), the SharePoint Server 2010 Chart Web Part, and certain Microsoft Visio 2010 scenarios that do not use Microsoft Silverlight 3.

Now if you have central admin permission, then you can follow the below steps.

1. Go to "Application Management" --> "Manage service applications"
2. Check whether the "State Service" is enabled or not (like the below screenshot). 

















3. If the service is not started or missed, we should configure/start the state service. OK. How to start the service?  proceed with step 4.
4. Go to the "Configuration Wizard" and start the configuration
5. Make sure the "State Service" is enabled. 
6.Wait until you see the below screen (It will take few minutes to complete).













7. Now, check whether the Chart control are rendering properly in the browser or not. If everything is fine, then continue with your work.. Again if you are getting the same error screen, you need to check the "Service Associations" for your current web application (proceed with step 8).

8. In "Central Administration", Go to "Application Management" and select the "Configure service application associations" in "Service Applications" section. 

9. Click on your web application and a pop up windows will be displayed






















10. Select the "State Service" Check box and click "OK".  

If you do not have permission, Or you do not want to configuration wizard(Like me), Then you can use powershell command as below:


$ErrorActionPreference = "Stop"


Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0

If you are using SharePoint SharePoint 2010 Management Shell then above two lines are not required.



function ConfigureStateService(
    [string] $stateServiceName = $(Throw "Value cannot be null: stateServiceName"),
    [string] $stateServiceDatabaseName =
        $(Throw "Value cannot be null: stateServiceDatabaseName"))
{
    Write-Host "Configuring the State Service..."

    Write-Debug "stateServiceName: $stateServiceName"
    Write-Debug "stateServiceDatabaseName: $stateServiceDatabaseName"

    $serviceApp = Get-SPStateServiceApplication -Identity "$stateServiceName" `
        -Debug:$false -EA 0

    If ($serviceApp -ne $null)
    {        
        Write-Host "The State Service has already been configured."
        return
    }
    
    $database = New-SPStateServiceDatabase -Name $stateServiceDatabaseName `
        -Debug:$false
    $serviceApp = New-SPStateServiceApplication -Name $stateServiceName `
        -Database $database -Debug:$false
    New-SPStateServiceApplicationProxy -ServiceApplication $serviceApp `
        -Name $stateServiceName -DefaultProxyGroup -Debug:$false > $null

Write-Host -Fore Green "Successfully configured the State Service."
}

function Main()
{
    $stateServiceName = "State Service"
    $stateServiceDatabaseName = "StateService"

    ConfigureStateService $stateServiceName $stateServiceDatabaseName
}

Main

And its done.

Monday, 11 February 2013

How to hide top navigation bar links without using Audiences


See this link.

Hide First Tab in SharePoint 2010 Navigation

I have two tabs let say Tab1 and Tab2. After activting "SharePoint Server Publishing Infrastructure" feature, I found that Tab link is showing one more tab named as Site name (Home, Tab1,Tab2).
I was trying to remove Home tab but not able to do the same.
After googling I found different solutions:
  1. This link is saying that, we need to do some modifications in master page as follows:
  •  Add <%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
  • Use
<PublishingNavigation:PortalSiteMapDataSource
     ID="topSiteMap"
       Runat="server"
         SiteMapProvider="CombinedNavSiteMapProvider"
           StartFromCurrentNode="true"
             StartingNodeOffset="0"
               ShowStartingNode="false"
                 TrimNonCurrentTypes="Heading" />
                  in place of 
                    <SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate">
                      <Template_Controls>
                        <asp:SiteMapDataSource
                           ShowStartingNode="False"
                             SiteMapProvider="SPNavigationProvider"
                               id="topSiteMap"
                                 runat="server"
                                   />
                                    </Template_Controls>
                                      </SharePoint:DelegateControl>

                                      It works. It will hid  Home tab. But issue is that when I clicked my Tab2, I found that focus is still on tab1. Means focus is not moving now from one tab to another on selection.

                                      I then reset my master page.

                                      Then I found this link. This link is showing to use css only.
                                      So in head section of master page I add following
                                      <style type="text/css">
                                      .s4-tn li.static > a{ 
                                      display: none !important; 
                                      .s4-tn li.static > ul a{ 
                                      display: block !important; 
                                      }
                                      </style>

                                      And wow. It worked.