Month: November 2009
SharePoint Site Template Size
When you turn an existing site into a template and include the content, there is a size limit of 10 Mb by default. If you site content is greater than this, a site template will not be created.
You can change this maximum size using an stsadm command on the SharePoint server.
stsadm -o setproperty -propertyname max-template-document-size -propertyvalue size_in_bytes
Where size can be up to 500Mb (524288000 bytes)
Windows PowerShell Out-Performing Stsadm Scenario
The Developer needs to activate a feature across 5,500 site collections. By using Windows PowerShell to run the Stsadm command, he came up with the following script to automate the work:
foreach ($site in (get-spsite -limit 5000000 -Webapplication $WebApp))
{
Write-Host “Activating feature ” $solutionName “on” $site.url “…”;
Write-Host stsadm “-o activatefeature -url” $site.url “-filename” $featureFileName;
stsadm -o activatefeature -url $site.url -filename $featureFileName
if( $lastexitcode -ne 0 )
{
Write-Host “Something went wrong activating the site feature. Exit code: ” $lastexitcode “`n” – ForegroundColor Red;
$failure = $true;
$error.Clear();
}
}
When he ran the script in her test environment, he found it took more than 12 hours to run. The Developer then decided to look for a better way of doing things. After talking to Grant, he found out there was built-in cmdlet to do this exact task. he then tried this script:
Get-SPSite –Limit ALL –WebApplication $WebAppNameorUrl |%{ Enable-SPFeature $FeatureIdOrName –url $_.Url }
The script ran in less than one hour. Lesson learned: If Stsadm.exe can do the operation, Windows PowerShell can do it too, and generally more efficiently.
SharePoint List Form Validation
You Can Use “PreSaveAction()” Function to Execute any JavaScript Code in New or Edit Forms. When Pressing OK button this Function will be Executed First
You Can Use this Function For Validation without PostBack
PreSaveAction()
{
//Add Your JavaScript Code Here Then Return True Or False
return false; // Cancel the item save process
return true; // OK to proceed with the save item
}