Wednesday, March 1, 2017

System.Web.HttpException: Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \\ section in the application configuration.

To fix this issue we have to do two changes in web.config file.

First open the web.config file from "C:\inetpub\wwwroot\wss\VirtualDirectories\" Web application Folder"".


  1.  Add the below code on module section.

<add name="Session" type="System.Web.SessionState.SessionStateModule" />




  1. Modify   enableSessionState = "false" to enableSessionState = "true" under pages section as below
<pages enableSessionState="true" enableViewState="true" viewStateEncryptionMode="Always" enableViewStateMac="true" validateRequest="false" pageParserFilterType="Microsoft.SharePoint.ApplicationRuntime.SPPageParserFilter, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" asyncTimeout="7">


Tuesday, February 21, 2017

Using PowerShell script how to increase the SharePoint site size.



Power shell command to increase the site size.

    Add-PsSnapin Microsoft.SharePoint.PowerShell

## SharePoint DLL
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$docSize = 524288000
$webservice = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$webservice.MaxTemplateDocumentSize = $docSize
$webservice.Update()

Using sharepoint PowerShell script how to save the site templates in web application.

$WebAppURL = "http://devportal.local"
$featureFolderName = "PublishingWeb"

$SiteCollections = Get-SPSite -WebApplication $WebAppURL -Limit All

foreach($Site in $SiteCollections)
{
    #Get all WebSites
    $WebsCollection = $Site.AllWebs
              
    #Loop through each WebSite
    foreach($Web in $WebsCollection)
    {
                    if ($Web.AllProperties["SaveSiteAsTemplateEnabled"] -eq "false")
                                {
                                    $Web.AllProperties["SaveSiteAsTemplateEnabled"] = "true"
                                                $Web.Update();
                                }
                  
                    $siteName = $Web.Name
                    $siteTitle = $Web.Title
                                $siteDescription = $Web.Description
                  
                                write-host "Save Site: " $siteTitle
                              
                    $Web.SaveAsTemplate($siteName,$siteTitle,$siteDescription,1)
                }
}


Sunday, February 19, 2017

Create Auto increment number Column in SharePoint List

Using below code we can show auto increment column number in SharePoint list.First download the Sputility.js file and jquery files after that create a SNO column with



<script src="/SiteAssets/jquery-3.1.1.js"></script>
<script src="/SiteAssets/sputility.js"></script><script>


    // Get the current Site
    var siteUrl = '/';

    function retrieveListItems() {

        var clientContext = new SP.ClientContext(siteUrl);
        // Get the liste instance
        var oList = clientContext.get_web().get_lists().getByTitle('Test List');

        var camlQuery = new SP.CamlQuery();

        // Get only the last element
        camlQuery.set_viewXml('<Query><OrderBy><FieldRef Name=\'ID\' Ascending=\'False\' /></OrderBy></Query><RowLimit>1</RowLimit></View>');
        this.collListItem = oList.getItems(camlQuery);

        clientContext.load(collListItem);

        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));      

    }

    function onQuerySucceeded(sender, args) {

        var listItemInfo = '';

        var listItemEnumerator = collListItem.getEnumerator();

        while (listItemEnumerator.moveNext()) {
            var oListItem = listItemEnumerator.get_current();

            var listItemInfovalue = oListItem.get_item('SNO');


 

            // create the new id
            SPUtility.GetSPField('SNO').SetValue(parseInt(listItemInfovalue) + 1);
        }

        console.log(listItemInfo.toString());
    }

    function onQueryFailed(sender, args) {
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    }



$(document).ready(function(){
    ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
    });</script>

Wednesday, February 15, 2017

This server machine in the farm does not have a 64 bit version of Windows Server 2008 SP2 or higher installed.

Solution:

 If you are planning to perform an in-place upgrade to SharePoint 2010, please upgrade the server machines in your farm to a 64 bit edition of Windows Server 2008 SP2 or higher, or migrate the current content databases from this farm to a new farm with servers running 64 bit edition of Windows Server 2008 SP2 or higher. Before attempting to install or upgrade to SharePoint 2010, please ensure that you run the SharePoint 2010 pre-requisites installer beforehand to ensure you have the correct set of prerequisites and patches installed. 

Sunday, February 12, 2017

Pragmatically approve the SharePoint workflow task items.

using below code we can approve the workflow task items.


 using (SPSite site = new SPSite(SPContext.Current.Web.Site.ID))
            {

                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["TestList"];
                    SPListItem item = list.GetItemById(47);

                    SPWorkflowTaskCollection taskCollection = new SPWorkflowTaskCollection(item, new SPWorkflowFilter());

                    foreach (SPWorkflowTask task in taskCollection)
                    {
                        //Check if the task is the manager's approval task
                        if (task[task.Fields["Status"].InternalName].ToString() != "Completed")
                        {
                            Hashtable ht = new Hashtable();
                            ht[SPBuiltInFieldId.Completed] = "TRUE";
                            ht["Completed"] = "TRUE";
                            ht[SPBuiltInFieldId.PercentComplete] = 1.0f;
                            ht["PercentComplete"] = 1.0f;
                            ht["Status"] = "Completed";
                            ht[SPBuiltInFieldId.TaskStatus] = SPResource.GetString(new CultureInfo((int)task.Web.Language, false), Strings.WorkflowStatusCompleted, new object[0]);
                            ht[SPBuiltInFieldId.WorkflowOutcome] = "Approved";
                            ht["TaskStatus"] = "Approved";
                            ht["FormData"] = SPWorkflowStatus.Completed;

                            web.AllowUnsafeUpdates = true;
                            SPWorkflowTask.AlterTask((task as SPListItem), ht, true);

                        }
                    }

                }
            }

Friday, February 10, 2017