Pages

Thursday 25 October 2012

Adding and Deploying solutions in SharePoint 2010

*** When a wsp is available ***

Adding a solution to the Solution Store

Add-SPSolution -LiteralPath <SolutionPath>

Deploy a solution

Install-SPSolution -Identity <SolutionName> -WebApplication <URLname>

To deploy a solution package to all Web applications

Install-SPSolution -Identity <SolutionName> -AllWebApplications -time <TimeToDeploy> -GACDeployment -CASPolicies


To upgrade an existing wsp solution file

Update-SPSolution –Identity mySolution.wsp –LiteralPath c:\mySolution.wspGACDeployment

To uninstall a solution

Uninstall-SPSolution –Identity mySolution.wsp –WebApplication http://webapp

To remove a solution

Remove-SPSolution –Identity mySolution.wsp

Extract a solution from the Content DB: SharePoint 2010

In order to gain access to a copy of a wsp file from the Config DB, follow these steps:

Powershell:

$farm = Get-SPFarm
$file = $farm.Solutions.Item("mySolution.wsp").SolutionFile
$file.SaveAs("c:\temp\mySolution.wsp")

To Get all solutions within a farm:
(Get-SPFarm).Solutions | ForEach-Object{$var = (Get-Location).Path + "\" + $_.Name; $_.SolutionFile.SaveAs($var)}

 

C#

using Microsoft.SharePoint
using Microsoft.SharePoint.Administration

namespace GetWSPFile
{
   class GetFile
   {
      static void Main(string[] args)
      {
           SPSolutionCollection AllSolutions = SPFarm.Local.Solutions;
           foreach (SPSolution solution in AllSolutions)
           {
              if(solution.Name =="mySolution.wsp")
              {
                     SPPersistedFile wspFile = solution.SolutionFile;
                     wspFile.SaveAs("C:\" + Solution.Name);
              }
           }
       }
    }
}

Installing a Feature when you only have access to the Feature Folder on the Server: SharePoint 2010

*** When you only have access to
the Feature folder ***
  • First, Copy the folder to the web front end / Central Admin server
Install to the farm:
Install-SPFeature FeatureFolderName

Enable at a site collection
Enable-SPFeature FeatureFolderName -Url http://server/site/subsite

Uninstall a featrure based on a folder:

Uninstall-SPFeature FeatureFolderName
Disable a feature for a site collection
Disable-SPFeature FeatureFolderName -Url http://server/site/subsite

Wednesday 24 October 2012

How to customise the New form for a document library in SharePoint 2010.

How to customise the New form for a document library in SharePoint 2010.


Note: This is not supported by Microsoft and it just a work around.

In order to create a custom New Form for a document library we will follow these simple steps:


  1. Create a list with exact content type (List settings > Advanced settings > Allow management of content types)
  2. Then click on the Customise Form (Infopath Icon)
  3. The form will open in Infopath
  4. Once the form is open select File > Publish > Export Source Files and save it in a desired location
  5. Edit the mainfest.xsf File in a text editor (I use Notepad++)
  6. Scroll down to bottom section where you should see this:



  7. We want to change the content type ID and the relativeUrl values here to point to the document library that we want to customise the new form for:
  8. In order to get the content type ID follow this post
  9. Change the Content type ID and Relative URL (for a document library just replace ../../ with the library name does not require a prefix library either)
  10. Save the mainfest.xsf
  11. Right click and select Design, now the form will point to the library, save and publish.

On a side note:
I have only tested this with a single content type




How to get the list ID and Content type ID in sharePoint 2010

To get the List ID:
  1. Navigate to list settings and copy List={ENCODED GUID}

    In my case it was this List=%7B2E5002B0-EDC3-4541-A0ED-2A81797B459C%7D
  2.  Decode the GUID here or here
  3. It should return a value similar to this: List={2E5002B0-EDC3-4541-A0ED-2A81797B459C}
That's it :)

To get the Content type ID currently associated with a list or library:

(Assuming allow management of content types is set to Yes (Under list settings > advanced settings))
  1. Navigate to list/library settings
  2. Under content types > select the content type
  3. From the URL copy this part:
    ctype=0x0100801F054C4E00C243A9A49EC13FF778D7003293EF8DE37E144BAA8A5296D5E6CA8B
  4. This the Content type ID