Pages

Saturday, 9 November 2013

Common and Useful PowerShell commands for SharePoint 2010/2013

Useful PowerShell commands for SharePoint

Working with SharePoint solutions
1.       Add Solution
Add-SPSolution c:\mysolution.wsp
2.       Install SharePoint Solution
Install-SPSolution  –Identity mysolution.wsp  –WebApplication http://spsite  -GACDeployment
3.       Update solution
Update-SPSolution –Identity mysolution.wsp –LiteralPath c:\ mysolution.wsp –GACDeployment
4.       Uninstall Solution
Uninstall-SPSolution –Identity mysolution.wsp –WebApplication  http://spsite  
5.       Remove solution
Remove-SPSolution –Identity MySharePointSolution.wsp
Working with SharePoint Features
1.       Install feature
Install-SPFeature “Feature Folder Name”
2.       Enable Feature
Enable-SPFeature “Feature Folder Name”  -Url  http://spsite
3.       Disable Feature
Disable-SPFeature “Feature Folder Name”  –Url  http://spsite
4.       Uninstall Feature
Uninstall-SPFeature “Feature Folder Name”
5.       Get All Features in the Farms
Get-SPFeature
In result it will provide you all feature with Display name, Id and scope. You can apply sorting, grouping on it
Sorting
Get-SPFeature | Sort -Property DisplayName/id/scope
Grouping
Get-SPFeature | Sort -Property Scope,DisplayName | FT -GroupBy Scope

6.       Get All  Features in Site Collection
Get-SPFeature -Site http://yousitecolletion
7.       Get All features in Web 
Get-SPFeature -Web http://youweburl
Back-Up and Restore Site Collection
1.       Back Up Site Collection
             Backup-SPSite -Identity http://yousitecolletion -Path  c:\sitebackup.bak -Force
2.       Restore SiteCollection
Restore-SPSite -Identity http://yousitecolletion -Path c:\sitebackup.bak  -Force



Thursday, 7 November 2013

SharePoint 2010 / 2013 Site Save As Template not available or not working

One of the best feature in SharePoint is saving site as template is missing or some time you got error. I face this issue many time.

  1. if you enable Publishing features you can see save as template option in site settings.
  2. some time due to Custom features you can save site as Template. Especially SharePoint 2013 you will got error "Some thing went wrong you can not save site as template" in log you can see this type of error 
       Microsoft.SharePoint.SPException: The "Save site as template" action is not supported on  this site.


its Difficult to identify what an issue , you have to go through the logs and based on Correlation ID you have to identify what's the error.
Solution:

  1. if publishing feature is enable , and your are not using any publishing feature , disable it , after disable the feature you can see the "Save as Template " in site settings or 
  2. if you require the Publishing feature then you can Edit the Url  and add  "/_layouts/15/savetmpl.aspx" at the end in SharePoint 2013 and add  "_layouts/savetmpl.aspx"  in SharePoint 2010. e.g http://myportal.com/sitea/_layouts/savetmpl.aspx
  3. using SharePoint Designer you can also change these settings. Open Site in SharePoint Designer , Default page at top right corner you can see the Site settings option , Click on it , and change SaveasTemplate value to true.




Wednesday, 6 November 2013

Business Connectivity services using Visual Studio 2010

Business Connectivity services using Visual Studio 2010
Using SharePoint Designer you can connect and communicate to external Database or Data. But you don’t have much control using SharePoint 2010 designer.

Other option is you can use Visual studio to write custom code to achieve External Content type. Using Custom code you have full control over the business logic to external Data Sources.
How it Works




BDC Runtime API which manipulate the External data, External content type behave similar like a SharePoint content types, you can manage security on external Lists, Default farms for add, edit, and delete are created , List are available for BI solution, Data in Lists are available for Search.


How to Create BCS Solution in Visual Studio 2010
1.       First we need to identify the Data Store/Database which we want to use as external Content type, in this example I am using very simple table with the name of Customers which contain only 3 columns. Database Table script is
Create TABLE [dbo].[Customers](
   [CustomerID] [int] IDENTITY(1,1) NOT NULL,
   [CustomerName] [nvarchar](50) NULL,
   [CusAddress] [nvarchar](50) NULL,
 CONSTRAINT [PK_Customers1] PRIMARY KEY CLUSTERED
(
   [CustomerID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

2.       Create new project using Visual studio 2010
3.       Select SharePoint project templates
4.       Select Business connectivity as Project type, Project name to solution and project and Press Ok





5.       Business connectivity Solution can only deployed as Farm solution, select the Site URL and Press finish button.




6.       After Finish button Visual Studio 2010 will Create Some structure for you



7.       Rename the File Entity1.cs to Customers.cs
This is entity Class; here we need to define entity like in my case entity is Customer

8.       Open the Code View of Customer.cs


9.       Remove the existing properties And write new properties based on your entity.

 private int _ID;
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        private string _CustomerName;

        public string CustomerName
        {
            get { return _CustomerName; }
            set { _CustomerName = value; }
        }
        private string _CusAddress;

        public string CusAddress
        {
            get { return _CusAddress; }
            set { _CusAddress = value; }
        }

10.    Now open the designer mode of BDC Model ,
11.    Rename the Model name. right click on Model -> select properties -> Change name to CustomersModel (can choose any name)
12.    Select the identifier -> open properties and rename to ID and change Type Name to System.Int32. As an Example ID is identifier

Friday, 1 November 2013

Business Connectivity Service (External Content types) using SharePoint Designer

Business Connectivity services
Simple definition is SharePoint able to communicate with external systems, Such as Microsoft SQL Server, Siebel, and SAP, or a Web service. Users can view, add, update, or delete business data by using external lists or Business Data Web Parts in SharePoint.


Benefits of BCS:
1.       Provide CRUD operations.
2.       Using SharePoint designer 2010 its need simple Steps required to complete its Configuration, so no programing knowledge is required.
3.       Visual studio is available to Write Code of Piece to Create Custom BCS.
4.       SharePoint Foundation, standard and enterprise Level
5.       Data is crawled using Search service and available in search results

Some Terms to Remember 

1.       External Content type
 It’s represent the schema for external object/External entity/ external data.
2.       External List
It’s Instant of External Object inside the SharePoint. Its behave similar like a SharePoint List

How to configure External Contact Type using SharePoint Designer 2010

Open site in SharePoint Designer and click on External contact types.


1.    Click to create new External Content type.



Provide the Name, Display Name; Select Office Item Type based on c its Contain (Generic List, Appointment, Contact, Task, and Post)


Connecting to Data Sources
1.       Click to discover External data Sources and define operations


2.      Click on add Connection button

3.       Choose Data source Option. (For Now choose SQL-Server)
4.       After that Provide Server name, Database name and Authentication type
Authentication Options:
·         Connect with user’s identity 
Use when u has SQL-Server and SharePoint on the same machine
·         Connect with Impersonated Windows Identity
Secure Store Service with windows ID (For Example Active Directory) will Use for it
·         Connect with impersonated Custom Identity
Secure Store Service with Custom ID (For Example SQL-Server ID’s) will Use for it.





It will take some time to explore Data source.  It will show Structure of provided Database.





5.       Select Required Table or View and Right click to generate operations. For now Click on “ Create All Operation




Setting up operations and properties




Press Next to parameter and identifiers (if Required to change , by default it populate based on database Structure )


Press Next to Set Filter (its use full when you have large amount of data), for now leave it blank and press Finish button.





Now you can see you Connection have all operation without any error. Press Save button at top left of the SharePoint Designer.


Creating External Lists and Verifying the Operations
1.       Open the site in browser
2.       Click on site actions , Press more Options
3.       Select the external List as template and press Create.



4.       Provide List Name, Description and select external content type. and press Create



After pressing create button you can see default all item View for that list and you will see all items from the Database table.



Add new item.

Verify from the Database




You can test by adding, updating and deleting the items from both ends, it will synchronize the data between SQL –Server table and SharePoint List.


Sample Database Script:

CREATE TABLE [dbo].[Product](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Title] [nvarchar](max) NOT NULL,
[Description] [nvarchar](max) NOT NULL,
[QTY] [int] NULL,
[Price] [float] NOT NULL,
[CategoryID] [int] NOT NULL,


Thursday, 24 October 2013

How to create multilingual Sites in SharePoint 2010

Language pack enables Site administrator to manage site in multiple languages. You’re not required to do any separate installation for to configure Multi-language.
Steps to Enable Multi Language in SharePoint 2010 Sites

Step 1: Download
             Select the Required language pack from given link
             Select required language and Press download.
Step 2: Install the language pack and Configure.
             Just run the setup and after installation run configuration manager.
Step 3: Site Administration
             Open the desired site and Go to -> site settings -> Site Administration -> language settings.
If you don’t have and extra language pack installed, language settings will not be available in Site
administration.


Click to setup language settings

Select the Required languages. In Given screen shot I have only language pack for Malay Language. After selecting your required language press Ok.



Select small icon on Login username and then you can see languages that you select in Site administration settings.



After selecting your required language you can see you site in different language.




Monday, 21 October 2013

SharePoint Download farm Solution from server.

When you deploy farm solution on server .
you can Retract Solution and can see other information related to it.


Monday, 30 September 2013

Logging in as a different user in SharePoint 2013 is Missing

In SharePoint 2013 Sign in as Different user is removed.



You can use sign in as different user  in 2 ways
Appent url with your Site URL  " /_layouts/closeConnection.aspx?loginasanotheruser=true"

Or 
Got to following path
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES\

Find Welcome.ascx  Open it, in any Editor

Add Following Text In  above ID_RequestAccess Element.



<SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser"  
Text="<%$Resources:wss,personalactions_loginasdifferentuser%>"   
Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>"   
MenuGroupId="100"   Sequence="100"   UseShortId="true"   />