Thursday 23 July 2015

Creating document library to site using powershell script

Creating document library to site using powershell script

[CmdletBinding()]

param ([Parameter(Mandatory=$true)] $SPSiteURL)

$ErrorActionPreference = "Stop"

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

function CreateSharePointFolder(

[Parameter(Mandatory=$true)] $SPWeb,

[Parameter(Mandatory=$true)] $ListTemplate,

[Parameter(Mandatory=$true)] $FolderName,

[Parameter(Mandatory=$true)] $Title,

[Parameter(Mandatory=$true)] $Description

)

{

$Folder = $spWeb.Lists.TryGetList($Title)

if($Folder -eq $NULL){

write-host "Creating new Document Library $Title"

$listId = $spWeb.Lists.Add($FolderName,$Description,$listTemplate)

$newList = $spWeb.Lists[$listId]

$newList.Title = $Title

$newList.OnQuickLaunch = "true"

$newList.Update()

}else

{

write-host "$Title already exists"

}

}

$spWeb = Get-SPWeb -Identity $SPSiteURL #http://splocal.ntlm

$listTemplate = [Microsoft.SharePoint.SPListTemplateType]::DocumentLibrary

CreateSharePointFolder -ListTemplate $listTemplate -FolderName "prefix_entityname1" -Title "Entity Display Name1" -Description "Entity description" -SPWeb $spWeb

CreateSharePointFolder -ListTemplate $listTemplate -FolderName "prefix_entityname2" -Title "Entity Display Name2" -Description "Entity description" -SPWeb $spWeb

 


Thursday 16 July 2015

The document records could not be loaded from SharePoint. Try refreshing the grid. If the problem persists, contact your system administrator

One of the project where we were using sharepoint and crm 2011 integration, user was able to see crm list component fine but when he/she tries to upload a document and then try to refresh the grid (using refresh icon on the list component), the document already present where no longer shown and also the whole grids gone blank with following error message

The document records could not be loaded from SharePoint. Try refreshing the grid. If the problem persists, contact your system administrator"


Solution: Make sure

1. User has got the site contributor permission (in this case user had)
2. Execute latest related crm 2011 sharepoint list component  (in this case we already done this)
3. Upload the lastest related crm 2011 sharepoint list component solution file having extension of wsp (this was the error, as we were thinking we had the same version but that wasn't the case), we can check this by downloading the uploaded solution wsp file from sharepoint and then compare it with the latest one ( i normally use beyound compare for this) but normally if there is a differnt you would tell normally by just looking at the file size.

https://community.dynamics.com/crm/f/117/t/141177