Thursday, October 31, 2013

Client object Model managed Code C# SharePoint



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Client;

namespace SPClient.NetConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            ClientContext clientContext = new ClientContext("http://igtehydzbnv02:8811/");
            Web site = clientContext.Web;
            List list = site.Lists.GetByTitle("TestListFilter");
            CamlQuery query = new CamlQuery();

            ListItemCollection itemColl = list.GetItems(query);


            clientContext.Load(itemColl);
            clientContext.ExecuteQuery();
            Console.WriteLine("Count: {0}", itemColl.Count);


            for (int i = 0; i < itemColl.Count; i++)
            {
                Console.WriteLine(itemColl[i]["Title"]);
            }
            Console.ReadLine();

        }
    }
}

Show SharePoint Error Page instead of Yellow ASP.Net error page

To show SharePoint errorpage do below changes in Web.Config file:

<SafeModeMaxControls="200"CallStack="false"DirectFileDependencies="10"TotalFileDependencies="50"AllowPageLevelTrace="false">

and

<customErrorsmode="On" />


To See Error message on Page itself do below changed in Web.Config file

<SafeModeMaxControls="200"CallStack="true"DirectFileDependencies="10"TotalFileDependencies="50"AllowPageLevelTrace="false">

and

<customErrorsmode="Off" />

Monday, October 28, 2013

File deployment to Site Assest or Style Library SharePoint

1. Add Empty Module to Solution
2. Create root folder inside empty module
3. Create Sub folders for JS, Images, CSS files.
4. Do File specific changes in Element.xml file

Sample Element.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="TestDeploy" Path="TestDeploy" Url="SiteAssets">
    <File  Url="BV/Sample.txt" Type="GhostableInLibrary"/>
  </Module>
</Elements>


Solution Snap Shot:-



Check dupliacte in list SharePoint ECMA Script : Client object model

Screen Shots:-

 
 Solution:-

Tuesday, October 22, 2013

Import / Export List in SharePoint using PowerShell

Exporting SPList :

 Export-SPWeb "<Site URL>" -itemurl "/Lists/<List Name>" -Path "D:\ListFolder\TestExport.cmp"


Importing SPList:

 Import-SPWeb -Identity "<Site URL>" -Path "D:\ListFolder\TestExport.cmp"



It will create list with same name in the target site.

Monday, October 14, 2013

Application pool keeps stopping / Service Unavailable in SharePoint Site / 503 error in SharePoint Site

One cause for this issue can be change in password for account with which Application pool is running for changing the Managed account password follow below blog post:
(Never change it from IIS directly)
 
If this is not your case then it can be below issue:
If you check the eventvwr logs you will see below entry in it:
The Module DLL 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\isapi\owssvr.dll' could not be loaded due to a configuration problem. The current configuration only supports loading images built for a x86 processor architecture.
 
Solution:
1.       Open IIS by typing inetmgr in RUN.
2.       Click on Application pools
3.       Click on particular Application pool for your site
4.       Right Click Advance settings
5.       Set Enable 32-bit applications to false


 

Saturday, October 12, 2013

Error While Adding/ Retracting SharePoint WSP

Error In PowerShell

Install-SPSolution : Admin SVC must be running in order to create deployment ti
mer job.


Error In Central Admin

The timer job for this operation has been created, but it will fail because the administrative service for this server is not enabled.






Solution:-

Monday, October 7, 2013

SharePoint Activate Feature using PowerShell


$spFeature= Get-SPFeature -Identity "<Feature Id from Feature.xml file>"

Enable-SPFeature $spFeature -Url "<Site Url>"

SharePoint document metadata not updating

I faced a weird issue today, Metadata for document which has lookup column was not updating even after saving the item. There was no erro...