Posts tagged with "Microsoft SharePoint"

Windows Server 2008 Disk Cleanup

Posted within Development on by Cornflower Design

SharePoint Central Admin has been prompting me, each time I’ve logged in, that one of my drives is running out of space. To be honest, there isn’t a lot that I can do – a small initial system drive and successive Windows updates have gradually eaten away at the free space – but I needed to free-up what I could.

The default install of Server 2008 doesn’t come with a disk clean-up option. You would normally have to install the “Desktop Experience” feature to get this option.

Handily, I found this post from Microsoft: Disk Cleanup option on drive’s general properties and cleanmgr.exe is not present in Windows Server 2008 or Windows Server 2008 R2 by default

Downloading Solutions from Central Administration

Posted within Development on by Ryan Ball

This is a handy little PowerShell snippet that I needed to use today. There were two .WSP solutions installed within the SharePoint farm and I couldn’t locate the original source code.

$farm = Get-SPFarm
$solution = $farm.Solutions.Item("MySharePointSolution.wsp").SolutionFile
$solution.SaveAs("C:\MySharePointSolution.wsp")

Hiding SharePoint WebParts via Code

Posted within Development on by Cornflower Design

Another note to myself…

When wanting to programmatically hide a WebPart, don’t try to set it’s Visible property to False. This will cause you lots of trouble and create errrors. The correct method is to set its Hidden property to True.

if (items.Count == 0)
{
   this.Hidden = true;
   return;
}

 

Set Up Groups for this Site

Posted within Development on by Cornflower Design

Note to self: Once a site has been created within SharePoint 2010, the ‘Set Up Groups for this Site’ admin page is hidden away – but you can set access it via /_layouts/permsetup.aspx.

SharePoint & Item-Level Permissions within Document Libraries

Posted within Development on by Ryan Ball

I have a love/hate relationship with SharePoint. Often the things that should be really simple, just aren’t. Take the ”Item-level Permissions” option for instance. Every list appears to have this option (available via List Settings > Advanced Settings) except for document libraries. I’m sure the SharePoint Development Team at Microsoft have a very good reason for this…

Step forth PowerShell!

$web = Get-SPWeb http://mysharepointsite
$list = $web.Lists[“A Document Library”]
$list.ReadSecurity = 2
$list.WriteSecurity = 2
$list.Update()
$web.Dispose()

The ReadSecurity value can be one of the following:

1 = “Read all items”
2 = “Read items that were created by the user”

The “Create and Edit access” option can also be set by specifiying a value for WriteSecurity.

1 = “Create and edit all items”
2 = “Create items and edit items that were created by the user”
4 = “None”

Hiding Fields in SharePoint 2010

Posted within Development on by Ryan Ball

This is a useful peice of PowerShell script to hide specific fields from the Edit form. ShowInEditForm can also be amended to ShowInNewForm.

$assignment = Start-SPAssignment
$web = Get-SPWeb http://mysharepointserver -AssignmentCollection $assignment
$field = $web.Lists["Announcements"].Fields["Body"]
$field.ShowInEditForm = $False
$field.Update()
Stop-SPAssignment $assignment

SharePoint: University College Falmouth Intranet

Posted within Doodles on by Cornflower Design

These design solutions were created as part of the University’s move from a 10 year old, bespoke, Classic ASP driven Intranet (which I originally developed) to Microsoft SharePoint 2010. Their purpose was to act as a starting point for discussion among staff and students and to generate feedback.

Homepage

Sub Page

SPListItem URLs

Posted within Development on by Cornflower Design

There seems to be no built-in function or property to quickly return the correct URL for a SharePoint list item. The obvious property, SPListItem.URL, always returns an invalid URL along the lines of http://sharepoint/Lists/MyList/155_.000. Not ideal.

To get around this and return a correctly formatted web address, you can use the following code:

item.Web.Url + "/" + item.ParentList.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url + "?ID=" + item.ID