Add List Template to all the site collections using Powershell

September 20, 2011 4 comments

Here is a way to upload a list template to all the site collections. Instead of going to all the site collections and upload the template manually .. use the script below to add them using Powershell

$GetSiteCollections = Get-SPWebApplication | Get-SPSite -Limit ALL
## Add the List Template to the all the Site Collections
foreach($GetSiteCollection in $GetSiteCollections)
{
$web = $GetSiteCollection.OpenWeb();
$spfolder = $web.getfolder("_catalogs\lt")
$spfileCollection = $spfolder.Files
$file = Get-Item c:\Temp\MyListTemplate.stp
spfileCollection.Add"MyListTemplate.stp", $file.OpenRead(),$true)
}

Thanks

Categories: SharePoint

Copy value from column to another using JQuery

August 19, 2011 1 comment

Copy the value from one column to another column on a New List Item Form.

In this example, I am populating the End Date Field with the Start Date Field value when user is filling out a meeting request form in SharePoint.

Add the following code on the page under “PlaceHolderMain” tag.

<script type="text/javascript" src="../../Shared Documents/Javascript/jquery/jquery.js">

$(document).ready(function(){
var strStartDate = $("input[title='Start Date']");
strStartDate.focusout(function()
 {
$("input[title='End Date']").val(strStartDate.val());
});
});
</script>

How to create Views Programmatically in SharePoint 2010

August 17, 2011 2 comments

Below is the code snippet to create views programmatically

Create a View

      private void CreateView(string strViewName)
{
try
{
string fieldName = //Get Field Internal Name
var docquery = "<Where><Eq><FieldRef Name='" + fieldName.ToString() + "' /><Value Type='Choice'>" + strViewName.ToString() + "</Value></Eq></Where>";
System.Collections.Specialized.StringCollection viewFields = new System.Collections.Specialized.StringCollection();
viewFields.Add("Type");
viewFields.Add("Name");
viewFields.Add("Modified");
viewFields.Add("Modified By");
viewFields.Add(fieldName.ToString());
oViewCollection.Add(strViewName, viewFields, docquery, 100, true, false);
web.Update();
}
catch (Exception e)
{
throw new SPException(e.Message.ToString());
}
}

You can use U2U Query Builder tool to build CAML query (http://www.u2u.net/res/Tools/CamlQueryBuilder.aspx)

 

Great blog about SharePoint Features , Elements and Scopt

July 12, 2011 1 comment

This blog helped me a lot in determining the scope of feature deployments.

http://weblogs.asp.net/soever/archive/2007/05/03/sharepoint-features-elements-scope-and-other-info.aspx

Categories: SharePoint Tags:

Comments History not showing on Custom Display Form

April 4, 2011 2 comments

Creating Custom Display Form in SharePoint Designer for a List does not show history for Comments field by default.
Here is the fix for that:

Replace:

<xsl: select=”@V3Comments” value-of disable-output-escaping=”yes”  />

Add:

<SharePoint:AppendOnlyHistory runat=”server” ControlMode=”Display” FieldName=”V3Comments” ItemId=”{@ID}”  />

This should fix the issue and start showing all the comments added in the Comments Field.

What value to use to set All Day Event in SPD Workflow

March 30, 2011 2 comments

Quick note:

If you want to set “All Day Event” in SharePoint Designer Workflow use Values 1 and 0

1 : Yes
0 : No

Hide Left Navigation Panel using CEWP

March 23, 2011 Leave a comment

Add a CEWP on the page.
Click on “HTML Source” from the Ribbon
Add the following :

#s4-leftpanel {
DISPLAY: none
}
.s4-ca {
MARGIN-LEFT: 0px
}

Click Ok.

Categories: SharePoint Tags: