Thursday, 2 December 2010

SharePoint Designer 2010 install problem

Finally I get to start doing a decent sized project in SharePoint Server 2010! I ran into a problem when setting up my development environment though. I'm using Windows Server 2008 R2 on an Oracle Virtualbox VM and its not on our domain so I wanted to install SharePoint Designer 2010 64 bit on it, rather than have a client install.

That should be easy, however after I had downloaded SharePoint Designer from Microsoft and ran the install I kept getting an error complaining about not being able to find SharePoint Designer.WW.cab. I guessed that it must be some problem with the extraction of that file from the exe so I cancelled the installation and then opened an elevated command window, navigated to where I had saved SharePointDesigner.exe and ran the following command:

sharepointdesigner.exe /extract:c:\transfer\extract

I didn't do anything else but re-run the installation and it worked fine that time.

Cheers,
Fraser

Tuesday, 26 October 2010

Custom SharePoint Timer Job

I've been creating a custom SharePoint timer using Andrew Connell's blog as a starting point.

It was driving me nuts for a while but I got it running in the end. His solution is for VS2005 but I'm using VS2008. To get it to build I had to delete the following 2 files:
  • BuildSharePointPackage.ddf
  • BuildSharePointPackage.Targets
I had to get rid of these because when you build it looks for makecab.exe which I don't have in my dev environment (Windows Server 2008 R2).

I prefer to use the SPVisualDev add-in for Visual Studio, so I added the SPVisualDev features to my project and dragged the Manifest.xml and Feature.xml files into the new feature folder that I named TaskLoggerJob (the same as the setting in the Manifest.xml file).

I then set the deployment settings:
Right click the project in VS -> SPVisualDev -> Artifact config -> Global config tab -> Assembly build type = GAC

I then built the WSP and deployed the solution using SPVisualDev.

In Central Admin -> Operations -> Solution Management I could then see the solution was globally deployed, however I couldn't see the feature anywhere in order to activate it. This is what is supposed to happen, what I had to do was activate it via STSADM on the command line.

I was now expecting to see it in the Timer job definitions list but it wasn't there and this is where I was confused because I had reset IIS too... I had to run STSADM -o execadmsvcjobs and then re-start the WSS Administration service and to get it to show up and run. The WSS Administration Service re-start is required because like IIS, it needs to be reset to pick up the fact that you have deployed the timer job DLL to the GAC.

See Andrew's blog for further links including a visual how to and explanations on why the timer job is not visible for activation via the UI.

Now that I know how to deploy it properly I'm going to modify it to poll a custom list and send emails.



Monday, 18 October 2010

Notes to self

\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query

Monday, 26 July 2010

Href tags being lost when updating a SharePoint Publishing HTML field in code

I had been banging my head against a wall today over this. Following on from my previous post, I wanted to update a Publishing HTML field to contain some links, however the href tags were being removed when I ran the SPListItem.Update().

The value I wanted to set the field to looked something like this:



This is a description of something with a link





I built up the HTML string in code and set the value of the href attribute to be "publishing-page.aspx", knowing that SharePoint would add the "pages/" for me. You would think this would work, but oh no, this is SharePoint.

I set the value of the field like so:

thePage.CheckOut();

theItem[fldHtml.Id] = newHtml.ToString();

// stepping through the code, theItem.Update() lost the href attribute altogether
theItem.Update();
thePage.CheckIn("");

thePage.ListItem.File.Publish("");
thePage.ListItem.File.Approve("");
pubWebSite.Update();


What you have to do is set the href attribute to include the site name and not just the page name. So you need to do this:



This is a description of something with a link





Hope that helps someone.

Cheers,
Fraser

Friday, 16 July 2010

Update MOSS publishing page properties programmatically

Today I had a requirement to add an additional property to over 200 MOSS 2007 publishing pages. Since there were over 200 pages I decided to do this in code rather than editing each page manually as this would be much faster and much less dull.

First off I had to add the property to the content type for the page. In this case it was a development code for a group of housing developments, so I added this as a string value and called it DevCode. I then had to think about how I was going to do the update...

Each publishing page obviously has a URL, so I asked the client to provide me with an Excel spreadsheet containing 2 columns matching up the URL for each housing development with the 3 digit code for the development. I then imported the Excel spreadsheet into a list in a SharePoint configuration site that I created earlier.

My plan was to now write a simple .Net windows application that could be run on the web front end server itself. Here is a brief synopsis of what the code does:

Upon clicking a button, the code will create a publishing site instance in order to get the collection of publishing pages. Once that is done we get the list containing the new codes with URLs from the configuration site, the plan being to loop round this list using the URL to find the page we're after in the publishing page collection.

Once the page is dug out of the page collection we need to find the DevCode field that we want to update, set the value to the new DevCode and perform the update on the item. Here is the complete code, C# as ever:


using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing;
using System.Configuration;

string url = string.Empty;
string devCode = string.Empty;

// open a web site
string pubSiteRoot = ConfigurationManager.AppSettings["PublishingSiteRoot"];
SPSite pubSite = new SPSite(pubSiteRoot);
pubSite.AllowUnsafeUpdates = true;
using (SPWeb pubWebSite = pubSite.OpenWeb())
{
if (PublishingWeb.IsPublishingWeb(pubWebSite))
{
// get the publishing web instance for this site
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(pubWebSite);

// get the collection of publishing pages
PublishingPageCollection ppages = publishingWeb.GetPublishingPages();

string cfgSiteRoot = ConfigurationManager.AppSettings["ConfigSiteRoot"];
SPSite cfgSite = new SPSite(cfgSiteRoot);
using (SPWeb cfgWebSite = cfgSite.OpenWeb())
{
//loop round the list items in the devcodes list
SPList liDevCodes = cfgWebSite.Lists["DevCodes"];

for (int i = 0; i < liDevCodes.ItemCount; i++)
{
url = "Pages/";

SPListItem item = liDevCodes.Items[i];
SPField fldUrl = item.Fields.GetFieldByInternalName("ows_Title");
SPField fldNewDevCode = item.Fields.GetFieldByInternalName("ows_DevelopmentCode");
url = url + item[fldUrl.Id].ToString().ToLower() + ".aspx";
devCode = item[fldNewDevCode.Id].ToString();

PublishingPage thePage = ppages[url];

if (thePage != null)
{
SPListItem theItem = thePage.ListItem;
SPField fldDevCode = theItem.Fields.GetFieldByInternalName("DevCode");

thePage.CheckOut();

theItem[fldDevCode.Id] = devCode;

// update the page, check in and publish

theItem.Update();
thePage.CheckIn("");
thePage.ListItem.File.Publish("");
thePage.ListItem.File.Approve("");
pubWebSite.Update();
}
url = string.Empty;
thePage = null;
}
}
}
}

Thursday, 15 July 2010

Annoying single-click to open an item (point to select) behaviour - Windows 7, XP

I've been experiencing an annoying setting that is applied by our office logon script. All credit to Rob Jones (http://www.motogpblog.com/) for the fix.

The Symptoms:
Check out folder options > click items as follows group
Double-click to open an item (single click to select) is enabled
However, your system is exhibiting the "Single-click to open an item (point to select)" behaviour which is both greyed out and not selected. How odd.

Here’s how to stop your mouse cursor selecting on hover in explorer windows.
1. Follow the instructions in this MSKB article:
http://support.microsoft.com/kb/555140
It will guide you to change a registry setting which will activiate the "Single-click..." option that is greyed out. Usual caveats apply, backup your registry etc. Instructions are for XP, but don’t let that stop you.
2. Reboot.
3. Navigate to folder options > click items as follows group
4. Select “Single click...” and apply.
5. Select “Double click...” and apply.
6. Enjoy using your mouse again.

Monday, 7 December 2009

Moodle Web Parts for SharePoint installation on 64 bit OS

There seemed to be a bit of confusion on the Codeplex forum for the Moodle web parts:

webparts to MOSS on 64 bit server

I managed to get these web parts installed on Windows Server 2008 Standard 64 bit. I believe that it is just the installer that doesn't work on 64 bit.

What I did was I ran the web service only installer first to create the web service. Then I ran the web parts only installer until it fell over and then located the extracted files. The file you are interested in is the .cab file called Moodle.WebParts.cab. I can't remember where it was extracted to but perform a search for that file name before you exit the installer and you will find it.

Then you can run the following stsadm command to install the web parts:

stsadm -o addwppack -filename "\Moodle.WebParts.cab" -globalinstall

Finally you will need to edit the configuration files manually because the installer is obviously not doing it for you. You need to change your settings in C:\Program Files\Common Files\microsoft shared\Web Server Extensions\wpresources\ProgXimity.Moodle.WebParts\1.5.0.0__09b750dbdb21d78d\moodle.config and also make sure your web service DAL.config settings are correct.

Hope that helps someone.

Cheers