Posts

Showing posts from September, 2010

Powershell Script that will deploy/upgrade Sandbox Solution.

Script that will let you deploy/upgrade a sandbox solution to a SharePoint 2010 site. Make sure that you at least an SharePoint site administrator before you run the script. # SharePoint DLL [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") #Cmdlet Install Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue ###REGION FUNCTIONS ##################################################################### #Adds a Sandbox solution to a site. ##################################################################### function AddSolution() { $myError = $null Add-SPUserSolution -LiteralPath $Solution -Site $SiteURL -ErrorAction:SilentlyContinue -ErrorVariable myError -Confirm:$false if ($myError -ne $null) { write-host -foregroundcolor 'red' $myError $myError = $null } else { Write-host -foregroundColor 'green' 'Sucessfuly added the solution to the site' } } ...

Tool to View Logs in SharePoint 2010.

How many of us working in SharePoint have the pure pleasure of trawling through SharePoint logs after opening them in Notepad. No greater fun than this to make your day. While searching for totally different thing, i came across the log view tool ULSViewer ULS Viewer  which makes the job of looking at SharePoint logs easy. It can monitor the logs realtime, meaning if you have a solution or a timer job deployed, you can use the ULS Viewer to see the any entries being written real time.

Updating Column Attributes in Custom Content Type - SharePoint 2010

While working on a project SharePoint 2010 recently, i started to create Custom Content Types and deploy them as a feature in a sand box solution. As with all things that change over time, i reealized that a couple of the fields that we thought were not required were in fact required fields. No big deal, i said, opened the Elements.Xml and went to the fields and set the value of the Required attribute to "True" and deployed the solution and said to myself that i am done.      Not so fast. When i went to the SharePoint site and looked at the content types, the two fields were still showing up as optional in the content types. After browsing through bing and google and not comming with anything, and then after trail and error found that the value of the "Required" attrubute should be set to "TRUE" and not "True". After i made this change, everything was working fine.

Create Announcements and other lists in a Publishing Site in SharePoint 2010.

Recently was working on a SharePoint project that involved creating Announcements list. When i went to create the Announcements, i could not find the Announcements list template. To have the template show up, i had to go to Site Action --> Site Settings and on the Site Settings page, under the section Site Actions, click on Manage Site Features and activate the "Team Collaboration Lists" features. This will now let you create Annoucements and other lists on your site.

Unable to use DateTimeControl in SandBox solution

If you are developing a web part in SharePoint 2010 and want to deploy the web part as Sandbox solution then you will not be able to use controls from SharePoint namespace like DateTimeControl. Also you will not able to do a Page.Redirect from a Sandbox web part. If you really need to do these things, then for now you will have to change your web part to a farm based solution rather than a Sandbox solution.

Dynamically populate the controls in a custom Web Part for SharePoint 2010

While working a custom web part in sharePoint 2010, came across a interesting issue where i had to load controls dynamically based on the value in a drop down control. If i load the controls in the index changed event for the drop down then i would be unable to access thier poperties later in the code. As all the controls aare stored in the Page.Request, in the CreateChildControls i used Page.Request[lstServcices.UniqueID]  to get the value of the drop down. After checking that the value in the Page.Request[lstServices.UniqueID] was not null, i wrote the code for creating the dynamic controls. Make sure that you use control..UniqueID, which is a combination of $ $ $ ,  and not Control.ID.