Wednesday, September 23, 2015

Control whether PDFs open in Word Web App or the default PDF reader

Control whether PDFs open in Word Web App or the default PDF reader

When users open a PDF file from a SharePoint document library that uses Office Web Apps Server, the default behavior is to open the PDF in Word Web App. If this isn’t the behavior you want, or if your users are having trouble opening PDFs on smartphones, you can use Windows PowerShell commands to make PDFs open in your default PDF reader instead. Here's how:

Step 1: Open an elevated SharePoint 2013 

Management Shell

On the computer running SharePoint Server 2013 or SharePoint Foundation 2013, open an elevated SharePoint 2013 Management Shell. Choose the procedure that corresponds to your server operating system:
  • In Windows Server 2008 R2:
    1. On the Start menu, select All Programs.
    2. Select Microsoft SharePoint 2013 Products.
    3. Choose (right-click) SharePoint 2013 Management Shell to display the shortcut menu.
    4. From the shortcut menu, choose Run as administrator.
  • In Windows Server 2012:
    1. Swipe in from the edge of the screen to show the charms and then choose Search to see all the applications that are installed on the computer.
    2. Choose (right-click) SharePoint 2013 Management Shell to display the app bar.
    3. In the app bar, select Run as administrator.

Step 2: Run the Windows Powershell Command

At the Windows PowerShell prompt, enter one of the following commands, based on what you want to do:
    • To adjust the binding so that smartphones won’t try to view PDFs in Word Web App (but other devices will continue to), enter the following command and then press Enter:
      Get-SPWopiBinding -Action "MobileView" -Application "WordPDF" | Remove-SPWopiBinding -Confirm:$false
    • To remove the binding altogether so that PDFs open in the default PDF viewer on all devices, use the following:
      Get-SPWOPIBinding –Application "WordPDF" | Remove-SPWOPIBinding -Confirm:$false

Going back

If you change your mind and later want to have PDFs open in Word Web App again, follow the same procedure as above, but in Step 2, run these two commands:
Get-SPWOPIBinding –Application "WordPDF" | Remove-SPWOPIBinding -Confirm:$false
New-SPWOPIBinding –ServerName "" –Application "WordPDF" -AllowHTTP
Be sure to use your own Office Web Apps server name instead of “”

Hope this help,

Monday, September 14, 2015

Add Custom Field to Folder Content Type in SharePoint 2010 List/Document Library

Add Custom Field to Folder Content Type in SharePoint 2010 List/Document Library

The Folder Content Type is sealed by default. We cannot customize it by adding any custom fields from the UI to the default Folder content type. Only way to do is going programmatic way. In real world, not all the SharePoint users are programmers. This PowerShell script enables the SharePoint users/administrators to simply run the script to accomplish the same.

#*******Script created by ACHKARI OUMAIMA************************************#
#*******To add custom columns to folder content Type*************************# 
#Check and add the necessary snapin 
if ( (Get-PSSnapin -Name microsoft.sharepoint.powershell -ErrorAction SilentlyContinue) -eq $null )  
Add-PsSnapin microsoft.sharepoint.powershell 
#Get the URL of the site 
$siteUrl = read-host -prompt "Please enter the url of the site where the list exists, (for example - http://contoso/sites/sitecol1/testsite) " 
 Write-Host "`n" 
#Get the Site Object 
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl) 
#Open the Web Object 
$web = $site.OpenWeb(); 
#Get the List/document Library to add custom column 
$list = $web.Lists["Espace Documentaire"]; 
#Get the content Types collection 
$ctypeCollection = $list.ContentTypes; 
#Get the content Type to Change, if english installation replace "Dossier" by "Folder" 
$ctype = $ctypeCollection["Dossier"]; 
#Get the field to add, its must be created in the list columns 
$field = $list.Fields.GetFieldByInternalName("Image");$fieldLink = New-Object Microsoft.SharePoint.SPFieldLink($field); 
#Add the custom column to the Folder Content Type 
$ctype.Sealed = 0; 
$ctype.Sealed = 1; 

Hope this help,

Optimising bulk inserts with Entity Framework 6

Optimising bulk inserts with Entity Framework 6 In Entity Framework 6+ the database context implements the  unit of work  pattern so th...