Thursday, July 28, 2011

ECMA script in SharePoint 2010

Hi,

ECMA Script is new in sharepoint 2010.First time when i got the task which should be done with ECMA script.But as i got 2 days,i couldn't do the task perfectly,my TL got bad impression.After some time there was requirement for my teammate in ECMA script,finally after googling i was able to do some POC's as below


Before writing the below code i have created a custom list with name 'Testlist',i have added another column with name 'Department' with type of single line of text

Below is the code to fetch the items from the list using ECMA script.For this added one CEWP on the page and through Edit HTML source of CEWP i have pasted below code




To debug this script actually i followed the below link,but as per opinion this method is not much affective as C# debugging,in some cases we couldn't get the value of the variable where we insert breakpoint
http://digsharepoint.blogspot.com/2011/04/how-to-know-all-methods-in-sharepoint.html

Below is the code to update List item using ECMA script

Monday, July 25, 2011

Error occurred in deployment step 'Retract Solution': Only a site collection administrator can activate or upgrade solutions that contain code.

Hi,

I got the above error when i was trying to deploy my sandbox solution.Finally with my teammates suggestion i deployed this sandbox solution into the site.Actually i created sandbox solution with my individual id,and it was throwing this error,to resolve i logged into the site with system account and added my id,finally it worked out.Below is the navigation path that i followed to add my id

Site Actions->Site Permissions->Click on 'Site Collection Administrators' under 'Edit' tab

Add the id through which you have created sandbox solution.Now deploy your sandbox solution right clicking on solution again.Finally sandbox solution gets deployed into the site

Thursday, July 21, 2011

Create,Add,Update and Delete List Items using PowerShell Script

Hi,

We had a requirement as follows with powershell

-For creating List,adding field in that list,
-Adding,Updating and Deleting all the list items

Finally after googling i found and implemented the task.Code is as below

//Creating and adding field to the list using powershell
$MyAssignment = Start-SPAssignment
$MyWeb = Get-SPWeb http://aaaa -AssignmentColl
ection $MyAssignment
$MyWeb.Lists.Add("My List","This list created with powershe
ll",$MyWeb.ListTemplates["Custom List"])

//Adding Field into the list
$MyList = $MyWeb.Lists["My List"]
$MyList.Fields.Add("TextField","Text",$MyWeb.FieldTypeDefin
itionCollection["Text"])
TextField
$MyWeb.Dispose()
Stop-SPAssignment $MyAssignment

//Adding ListItem
$spAssignment = Start-SPAssignment
$mylist = (Get-SPWeb -identity http://aaa -As
signmentCollection $spAssignment).Lists["My List"]
$newItem = $mylist.Items.Add()
$newItem["Title"] = "Added by Powershell"
$newItem["TextField"] = "My PowerShell Magic"
$newItem.Update()

//Deleting all ListItems
[System.Reflection.Assembly]::Load("Microsoft.SharePoint, V
ersion=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")

[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Po
rtal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")

[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Pu
blishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")

[System.Reflection.Assembly]::Load("System.Web, Version=2.0
.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

$SITEURL = "http://aa"
$site = new-object Microsoft.SharePoint.SPSite ( $SITEURL )

$web = $site.OpenWeb()
"Web is : " + $web.Title

# Enter name of the List below
$oList = $web.Lists["My List"];

"List is :" + $oList.Title + " with item count " + $oList.I
temCount

$collListItems = $oList.Items;
$count = $collListItems.Count - 1

for($intIndex = $count; $intIndex -gt -1; $intIndex--)
{
"Deleting : " + $intIndex
$collListItems.Delete($intIndex);
}

Friday, July 8, 2011

Useful Posts of SharePoint 2010

Hi,

Below are some posts of sharepoint 2010 that i found very useful and learnt/learning a lot.Hope this may be useful too as well to googlers who have eager to learn more in sharepoint 2010

//Hide I Like It and Notes and Tags
http://www.sharepointkings.com/2011/07/hide-i-like-it-and-notes-and-tags.html

//Silver light client object model
http://www.sharepointkings.com/2011/07/client-object-model-part-2.html?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+SharepointKings+%28Sharepoint+Kings%29

//SharePoint 2010 Cookbook: Create a Slide Image Web Part Using jQuery
http://community.bamboosolutions.com/blogs/sharepoint-2010/archive/2011/07/08/sharepoint-2010-cookbook-create-a-slide-image-webpart-using-jquery-in-sharepoint.aspx

//Using jQuery with SharePoint 2010
http://blogs.msdn.com/b/yojoshi/archive/2010/06/17/using-jquery-with-sharepoint-2010.aspx

//Programmatically add Javascript or CSS to pages in SandBox web part
http://stsadm2010.blogspot.in/2011/12/programmatically-add-javascript-or-css.html

//What is Sandbox Solutions in SharePoint 2010?
http://geekswithblogs.net/venkatx5/archive/2010/11/23/what-is-sandbox-solutions-in-sharepoint-2010.aspx
http://www.chakkaradeep.com/post/SharePoint-2010-Sandboxed-Solutions.aspx

//How to Create Multilingual Webpart in SharePoint 2010?
http://geekswithblogs.net/venkatx5/Default.aspx

//Site Workflow in SharePoint 2010
http://www.sharepointkings.com/2012/05/site-workflow-in-sharepoint-2010.html?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+SharepointKings+%28Sharepoint+Kings%29

//Integrating Facebook comments into SharePoint
http://www.sharepointkings.com/2012/02/integrating-facebook-comments-into.html?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+SharepointKings+%28Sharepoint+Kings%29

//Connectable web parts in MOSS / SharePoint 2010
http://www.sharepointkings.com/2012/05/connectable-web-parts-in-moss.html?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+SharepointKings+%28Sharepoint+Kings%29

Data Sheet View of SharePoint 2010 lists

Hi,

Normally Data Sheet View comes up after installing Office 2010 for sharepoint site.There will be a situation where you need datasheet view for bulk copy/paste of list items,at that moment if we don't have Office 2010 then we can install Access2007Runtime.exe.After installing this we can get DataSheetView of list only through IE browser