Tuesday, 12 August 2014

Save & Send - Save to SharePoint option missing in file menu (excel/doc etc.)

please refer to this link
http://www.cloudnetworks.com.au/support/save-to-sharepoint-is-missing-from-the-file-menu-in-word/ 

Sunday, 1 June 2014

Power shell command to check event receivers associated to a list/library

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get the web
$Web = Get-SPWeb "<website>"

#Get the Target List
$List = $Web.Lists["Document"]

#Retrieve all event receivers associated with the list
$List.EventReceivers | Select Id, Type, Assembly, Class | FL

Tuesday, 6 May 2014

Things to keep in mind while developing apps for SharePoint which expects anonymous user access

Things to keep in mind while developing apps for SharePoint which expects anonymous user access

A very common discussion topic in the SharePoint app world is , what are the points that we need to keep in mind when designing an app for anonymous users in a public site.

This issue comes up as there are many restrictions for anonymous users to access resources in a SharePoint world.

This MSDN documentation gives a clear documentation on the dos and don'ts while designing an app.
This link also guides developers, users and admins on the different considerations we need to keep in mind.

Saturday, 25 January 2014

Friday, 24 January 2014

Using before, after properties and properties.listItem in SharePoint event receivers

While handling business requirements in event receivers, we often need to handle common scenarios with before and after properties.

The behavior of these properties is different for a list and a library. Below is a summary of the behavior.

List:

List
BeforeProperties
AfterProperties
properties.ListItem
ItemAdding
No value
New value
Null
ItemAdded
No value
New value
New value
ItemUpdating
No value
Changed value
Original value
ItemUpdated
No value
Changed value
Changed value
ItemDeleting
No value
No value
Original value
ItemDeleted
No value
No value
Null

Library:

Library
BeforeProperties
AfterProperties
properties.ListItem
ItemAdding
No value
No value
Null
ItemAdded
No value
No value
New value
ItemUpdating
Original value
Changed value
Original value
ItemUpdated
Original value
Changed value
Changed value
ItemDeleting
No value
No value
Original value
ItemDeleted
No value
No value
Null



Thursday, 5 December 2013

Adding content editor web part with default content through Visual Studio

Content editor web parts are very handy in many purposes and it is used a lot nowadays. A typical requirement that I have come across, is to add a content editor web part, with some default content to a page through visual studio. The requirement looks quite simple. But there are few areas which we need to keep in mind to get this working as expected.
One aspect being the HTML content within the CEWP does not render as HTML rather it renders as plain text. This is explained int the last step.

The steps which we need to follow are :

  • add a page to through visual studio ( for our example we will add a page to the site pages gallery)
  • add a web part zone to the page

<asp:Content id="Content5" ContentPlaceHolderId="PlaceHolderMain" runat="server">         <table class="ms-core-tableNoSpace ms-webpartPage-root" width="100%"> <tr> <WebPartPages:WebPartZone runat="server" Title="CETestWebPart" ID="CETestWebPart" FrameType="TitleBarOnly"><ZoneTemplate> </ZoneTemplate></WebPartPages:WebPartZone> </tr> </table></asp:Content>

  • modify the elements.xml to add the content editor web part properties. An easy workaround to get all the properties correct is to create a CEWP on a page using UI and then exporting it. Then open it in a notepad. 
    • Add an allUsersWebPart , add a guid. Under <![CDATA[ put all the code copied from the notepad, till <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"> 
  • within the content area add the default html in encoded format for the Content editor web part content. There are many HTML encoding decoding tool available online.
The final elements.xml will look like this :

 <File Path="SitePages\CEWebPart.aspx" Url="CEWebPart.aspx" Type="GhostableInLibrary" >
      <AllUsersWebPart WebPartOrder="1" WebPartZoneID="TestCEWP" ID="g_33268769_B61B_4665_8FF3_1BE038F0AB58">
        <![CDATA[
        
        <?xml version="1.0" encoding="utf-8"?>
<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
  <Title>Content Editor</Title>
  <FrameType>Default</FrameType>
  <Description>Allows authors to enter rich text content.</Description>
  <IsIncluded>true</IsIncluded>
  <ZoneID>wpz</ZoneID>
  <PartOrder>0</PartOrder>
  <FrameState>Normal</FrameState>
  <Height />
  <Width />
  <AllowRemove>true</AllowRemove>
  <AllowZoneChange>true</AllowZoneChange>
  <AllowMinimize>true</AllowMinimize>
  <AllowConnect>true</AllowConnect>
  <AllowEdit>true</AllowEdit>
  <AllowHide>true</AllowHide>
  <IsVisible>true</IsVisible>
  <DetailLink />
  <HelpLink />
  <HelpMode>Modeless</HelpMode>
  <Dir>Default</Dir>
  <PartImageSmall />
  <MissingAssembly>Cannot import this Web Part.</MissingAssembly>
  <PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>
  <IsIncludedFilter />
  <Assembly>Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
  <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
  <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
  <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
  
     &lt;div&gt;test content for the CEWP &lt;/div&gt;       
             
  </Content>
        <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
        </WebPart>
        
        ]]>
      </AllUsersWebPart>
    </File>

To make the content within CEWP render as HTML we need to encode the content. If we put direct HTML SharePoint will remove all HTML elements and everything will be put under a single DIV. Hence the HTML will be rendered as plain text.


You can find the whole project at this location
https://github.com/debopamb/SPGithub/tree/master/CEWebpartProj

Thursday, 14 November 2013

Creating SharePoint site collections using powershell

We come across this scenario very often. We need to create a SharePoint site collection using an existing site template using power shell script.
To find the available templates you can use the below command :

Add-PSSnapin Microsoft.SharePoint.PowerShell
Get-SPWebTemplate | Sort-Object "Title"

Some of the widely used templates are

SRCHCENTERLITE#1     Basic Search Center
BLOG#0                            Blog
BICenterSite#0                   Business Intelligence Center
SRCHCEN#0                     Enterprise Search Center
CMSPUBLISHING#0        Publishing Site
WIKI#0                              Wiki Site


The below script will create a site collection using Enterprise Search Center

try
{
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue
 
## create the prerequisite

$webApplicationUrl = "http://server"
$siteCollectionUrl = "http://server/sites/SearchCenter"
$siteCollectionName = "Search Center"
$siteCollectionOwner1 = "DOMAIN\user1"
$siteCollectionOwner2 = "DOMAIN\user2"
$siteCollectionTemplate = "SRCHCEN#0"

 ## Check if the site collection exists or not
$SiteCollection = Get-SPSite $siteCollectionUrl -ErrorAction SilentlyContinue if ($SiteCollection -ne $null) { Write-Host "Search center already exists at " $siteCollectionUrl } else { ## Create the site collection New-SPSite -URL $siteCollectionUrl -OwnerAlias $siteCollectionOwner1 -SecondaryOwnerAlias $siteCollectionOwner2 -Name $siteCollectionName -Template $siteCollectionTemplate Write-Host "Search center created successfully" }
}
 
catch { Write-Host -ForegroundColor red "There were some problem in creating the search center" }





You can use any template as per availablilty .