Tags » Sharepoint 2010

Start Stop SharePoint timer Service using command line

Many time while working withe timer job to get the new  code changes we need to restart timer service.

Below are the cmd command that can be used to stop and start timer service… 30 more words

Sharepoint 2010

Audience targetting not working

Hi! Today a customer calls me complaining about SharePoint. They have configured a web application with several site collections, and several webparts in each site. 154 more words

Sharepoint 2013

A Problem Occurred While Connecting to the Server

We’ve all gotten this error before.

This can mean any number of things. This article will describe a very specific situation that we discovered with one of our users. 447 more words

Sharepoint

Best Practices and Considerations For Implementing Workflows in SharePoint

I recently presented at the 7th annual SharePoint Saturday event in Atlanta. For those who aren’t familiar, SharePoint Saturday is a community‐focused SharePoint event dedicated to educating and engaging members of the local SharePoint community.  234 more words

Sharepoint 2013

Check if a date field is blank in a SharePoint Designer workflow

When creating a workflow in SharePoint Designer, you often want to use a condition that a date field is blank. There is no option in the drop-down for… 115 more words

Sharepoint 2010

Set a SharePoint Calculated Column as hidden in a content type

Sometimes, we just create a calculated column to do some task and we do not want to show these fields in the display forms of SharePoint. 158 more words

Sharepoint 2010

Create Site Columns, Content Type and Add to Library using PowerShell

A good script to have for testing.

Add-PSSnapIn "Microsoft.SharePoint.Powershell"
#Get the site collection and web object
$siteColl = Get-SPSite -Identity "https://portal.contoso.com"
function Create-SiteColumnText ($siteColl, $CustomColumn)
{
    $rootWeb = $siteColl.RootWeb
    #Assign fieldXMLString variable with field XML for site column
    $fieldXMLString = "<Field Type='Text' Name='$CustomColumn'
    Description='Indicate date of last and next meeting and names of current members.'
    DisplayName='$CustomColumn'
    StaticName='$CustomColumn'
    Group='Custom Columns'
    Hidden='FALSE'
    Required='FALSE'
    Sealed='FALSE'
    ShowInDisplayForm='TRUE'
    ShowInEditForm='TRUE'
    ShowInListSettings='TRUE'
    ShowInNewForm='TRUE'></Field>"
    #See field XML on console
    #write-host $fieldXMLString
    #Create site column from XML string
    $rootWeb.Fields.AddFieldAsXml($fieldXMLString) 
    Write-Host "Column Added"
}

function Create-SiteColumnChoice ($siteColl, $CustomColumn)
{
    $rootWeb = $siteColl.RootWeb
    #Assign fieldXMLString variable with field XML for site column
    $fieldXMLString = "<Field Type='Choice' 
    Name='$CustomColumn'
    Description='Choice.'
    Format='Dropdown'
    DisplayName='$CustomColumn'
    StaticName='$CustomColumn'
    Group='Custom Columns'
    Hidden='FALSE'
    Required='FALSE'
    Sealed='FALSE'
    ShowInDisplayForm='TRUE'
    ShowInEditForm='TRUE'
    ShowInListSettings='TRUE'
    ShowInNewForm='TRUE'>
    <Default>Specification</Default>
                <CHOICES>
                  <CHOICE>Specification</CHOICE>
                  <CHOICE>Development</CHOICE>
                  <CHOICE>Test</CHOICE>
                  <CHOICE>Documentation</CHOICE>
                </CHOICES>
    </Field>"
    #See field XML on console
    #write-host $fieldXMLString
    #Create site column from XML string
    $rootWeb.Fields.AddFieldAsXml($fieldXMLString) 
    Write-Host "Column Added"
}


Create-SiteColumnText -siteColl $siteColl -CustomColumn "MyCustomColumn1"
Create-SiteColumnText -siteColl $siteColl -CustomColumn "MyCustomColumn2"
Create-SiteColumnText -siteColl $siteColl -CustomColumn "MyCustomColumn3"
Create-SiteColumnChoice -siteColl $siteColl -CustomColumn "MyCustomColumn4"

$web = $siteColl.RootWeb
$ctypeName = "MyCustomContentType"
$ctypeParent = $web.availablecontenttypes["Document"]
$ctype = new-object Microsoft.SharePoint.SPContentType($ctypeParent, $web.contenttypes, $ctypeName)
$web.contenttypes.add($ctype)
$field = $web.fields.getfield("MyCustomColumn1")
$fieldLink = new-object Microsoft.SharePoint.SPFieldLink($field)
$ctype.fieldlinks.add($fieldLink)

$field = $web.fields.getfield("MyCustomColumn2")
$fieldLink = new-object Microsoft.SharePoint.SPFieldLink($field)
$ctype.fieldlinks.add($fieldLink)

$field = $web.fields.getfield("MyCustomColumn3")
$fieldLink = new-object Microsoft.SharePoint.SPFieldLink($field)
$ctype.fieldlinks.add($fieldLink)

$field = $web.fields.getfield("MyCustomColumn4")
$fieldLink = new-object Microsoft.SharePoint.SPFieldLink($field)
$ctype.fieldlinks.add($fieldLink)
$ctype.Update()

$Library =$Web.Lists["Documents"]
$Library.ContentTypesEnabled = $true

$Library.ContentTypes.Add($ctype);
$Library.Update()
SharePoint 2013