Sunday, 17 April 2016

SharePoint Online List Creation PowerShell


#Reference http://blogs.technet.com/b/fromthefield/archive/2014/02/18/office365-script-to-create-a-list-add-fields-and-change-the-default-view-using-csom.aspx

#Create List in SharePoint Online

#Specify tenant admin and site URL

$User = "explore@<domain>.onmicrosoft.com"

$SiteURL = "https://<NAME>.sharepoint.com/<SUBSITE>"

$ListTitle = "ListDemo"



#Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"

Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

$Password = Read-Host -Prompt "Please enter your password" -AsSecureString

$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)



#Bind to site collection

$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)

$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)

$Context.Credentials = $Creds



#Retrieve lists

$Lists = $Context.Web.Lists

$Context.Load($Lists)

$Context.ExecuteQuery()



#Create list with "custom" list template

$ListInfo = New-Object Microsoft.SharePoint.Client.ListCreationInformation

$ListInfo.Title = $ListTitle

$ListInfo.TemplateType = "100"

$List = $Context.Web.Lists.Add($ListInfo)

$List.Description = $ListTitle

$List.Update()

$Context.ExecuteQuery()



#Retrieve site columns (fields)

$SiteColumns = $Context.Web.AvailableFields

$Context.Load($SiteColumns)

$Context.ExecuteQuery()



#Grab city and company fields

$City = $Context.Web.AvailableFields | Where {$_.Title -eq "City"}

$Company = $Context.Web.AvailableFields | Where {$_.Title -eq "Company"}

$Context.Load($City)

$Context.Load($Company)

$Context.ExecuteQuery()



#Add fields to the list

$List.Fields.Add($City)

$List.Fields.Add($Company)

$List.Update()

$Context.ExecuteQuery()



#Add fields to the default view

$DefaultView = $List.DefaultView

$DefaultView.ViewFields.Add("City")

$DefaultView.ViewFields.Add("Company")

$DefaultView.Update()

$Context.ExecuteQuery()



#Adds an item to the list

$ListItemInfo = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation

$Item = $List.AddItem($ListItemInfo)

$Item["Title"] = "New Item1"

$Item["Company"] = "Contoso"

$Item["WorkCity"] = "London"

$Item.Update()

$Context.ExecuteQuery()




Sunday, 10 April 2016

SharePoint Online Coding Cheklist

SharePoint Online Review Checklist

Custom Code

This section defines the checklist for any coding or customizations in SharePoint environment.
⃝
This feature or functionality is NOT supported by Out of Box features through Browser
⃝
This feature or functionality is NOT supported by no code solutions.
⃝
A Developer site is created to host all the custom apps or add ins
⃝
The custom code is backed up in a reliable location(s)
⃝
Exception Handling is done for custom code.
⃝
Is the application scalable to mobile?
⃝
Is the app tested as a package on UAT and development server?
⃝
Does the code follow best practices to handle large list data

APPS
⃝
Is this Intranet, Extranet or Internet App?
⃝
Does the installer have Site Owner rights to install apps?
⃝
Has the App catalog been configured to install Apps?
⃝
The app domain is not a subdomain. Not apps.contoso.com[contosoapps.com]
⃝
The app domain should be in the Internet or Restricted sites security zone in Internet Explorer.
⃝
Prefixes must be less than 48 characters and cannot contain special characters or dashes
⃝
Is the app tested as a package on UAT and development server or site collection?
⃝


Reference
https://technet.microsoft.com/en-us/library/fp161237(v=office.15).aspx