WSS – ONET

July 8th, 2009 No comments

Whilst messing with a product some contractor of ours did for us (SURJIT I’m talking about you).  I discovered a lovely piece of code.

The SiteDef had some SiteProvisioning code, it read an XML file to do additional processes as part of the site provisioning, rather handy in some cases.

But I did notice a few oddities.

In SiteProv he was creating lists.  Also He was copying files from the file system into Lists.  Some users just don’t have access to this part of the file system and this was exploding.

Two things about this technique,

  • 1st. You can Provision Lists in the ONET.
  • 2nd You can copy files into lists in the ONET.

The first item he should have known, so WHY do it as part of site provisioning event ?  I don’t know. Perhaps something to do with sequence, perhaps stupidity ;-) .

Second I can forgive, someone not trained in SharePoint might not know exactly what the <Module> Tag is really for.

Think of the <Module> tag in Features and SiteDefs as a kind of File copy as well as configuring what webparts go where on a page, it can copy files from the file system into a DocLibrary, but most importantly it has the correct rights to do it.

Some extra info on ONET’s and Modules.

From all the examples you have seen in existing SiteDefs the most likely arrangement would be something like this

Read more…

Categories: Uncategorized Tags:

WSS – Solutions

July 8th, 2009 No comments

Just a silly one.

I’ve decided to call the WSP solution packages for WSS, Wasps.

It really appeals to me that I can send our support department a bunch of wasps.

 

Technorati Tags: ,,
Categories: Uncategorized Tags:

WSS 3.0 – My {insert problem here} don’t work

July 6th, 2009 No comments

There’s some special secret code they don’t tell you about whenever something doesn’t work.

You change a list or a web or something and nothings happens.

It’s called the Update() method.  Sshhhhh don’t tell anyone.

;-)

 

Technorati Tags: ,,
Categories: Uncategorized Tags:

Hands up if you hate STP’s

June 30th, 2009 No comments

Is it me ?  Have I missed something ? Are STP’s the best thing on the planet for quickly creating SharePoint sites ?

Or is it as I believe the biggest pain in the backside for SharePoint developers to pick up someone else’s SharePoint project to make changes to the site definition pages only to discover they were hacked together in the interface saved as an STP and included in your project.

This is now the case for me on two of my inherited projects, I hate them.  Now I know that if you create standard site templates with an onet etc, once created, there are elements of the definition that are now content and would have be be manipulated via the API to change them (or interface). But consider if you have a problem and are searching in a HUGE project for where your specific list might be or other such content, can you find in in Studio by searching ? No you can’t cos it’s all cabbed up in a file.

So my advice to anyone even considering using STP’s, think again are you doing it cos it’s quick and your a contractor soon to leave the company anyway so what the hell, or are you a developer who might have to make changes and maintain your project.  Seriously think twice, is this the best way to develop this solution, is there some advantage to an STP over a site def ? think before you start hacking away.

Technorati Tags: ,,
Categories: Uncategorized Tags:

Sharepoint Versioning – Gotcha 2

June 10th, 2009 No comments

I’ve had a right game with this Sharepoint Versioning problem.

Now those of you used to writing .NET but maybe not SharePoint will be used to having AssemblyVersion attributes set in the AssemblyInfo.cs files.

This is something I took into my last SharePoint application for wss3.  Now in SharePoint 2003 I got used to not setting the version number but it slipped my mind for WSS 3.0.

My particular problem was I had some ItemAdding/Updating List events.  These were configured to fire in one of my Assemblies. My build server would automatically increment version numbers in AssemblyInfo.cs and in all associated .xml files in the features, very clever I thought at the time.  Now I needed to update this assembly and modify some code in these events.

I made those changes and installed it and all of a sudden none of the events were firing at all.

This is because when a list is created the EventReceiver details of the feature are not read from the XML file but are stored against the List in the content database.  This makes some sense as if you update the list template then you can update the EventReceivers as well and have different versions of a list definition with different handlers.

In my experience it’s more likely that you will want to modify all the existing lists and template as your probably implementing a fix, especially if using SharePoint as an app platform.

So how to fix my now rogue ItemReceivers.  I could do some fancy coding in Feature activations etc, but I really don’t want to go there and have code left lying about for what will essentially be a one time fix.

To the rescue PowerShell.  Luckily for me we use PowerShell so I  can create a post update installation script that runs just this once.

Here is the gist of it.

###############################################################
# Validate args
###############################################################

    if ($args.Length -ne 1 -or $args[0] -eq "-?")
    {
        Write-Host "Usage: .\FixIt.ps1 <SiteUrl>";
        return;
    }
    $SiteUrl = $args[0];
    cls

###############################################################
#Get Base Objects
###############################################################

    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    $site = New-Object Microsoft.SharePoint.SPSite $SiteUrl
    $web = $site.RootWeb
    $lists=$web.Lists

###############################################################
#Change List Event Receivers
###############################################################

$list=$lists["BrokenList"]

#I happen to know there are only 4 Receivers really I should use the count
#One of them is named wrong as well hence the 3 cases
#(in the real version I fixed that too)
#You need to count backwards as it deletes and re-inserts so a foreach wont #work.

for ($i=3;$i -ge 0;$i–)
{
    $er=$list.EventReceivers[$i]
    switch($er.Name)
    {
        "BinaryJam BrokenList Receiver ItemUpdating"
        { 
            $er.Assembly="BinaryJam.MySharePointApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1111111111111111"
            $er.Update()
        }
        "BinaryJam BrokenList Receiver ItemAdded"
        {
            $er.Assembly="BinaryJam.MySharePointApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1111111111111111"
            $er.Update()
        }
        "BinaryJam BrokenList Receiver ItemAdding"
        {
            $er.Assembly="BinaryJam.MySharePointApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1111111111111111"
            $er.Update()
        }
    }
}

$list.Update()

 

Categories: development, Sharepoint Tags:

WSS 3 – AssemblyVersion – Gotcha

June 4th, 2009 No comments

Well what a great gotcha I had today.  I have a WSS application you know custom list templates, event receivers web parts, everything you can think of except workflow.

So I have an upgrade for this, its a new dll and feature files.  I use a build server that can automatically update the AssemblyVersion and automatically edit the dwp aspx ascx files etc to set the version number of the build, its very slick.

Forgetting one thing.  SharePoint has never liked Version numbers. So I applied the update and my webpart fails with safe control errors. 

I forgot when you add the webparts it copies the dwp complete with version number into the content database and I just uninstalled that DLL. DOH! 

After figuring this out with the help of Captain Literal.Net, I stopped my build auto updating the versions and grepping the files etc.  It still marks the file version number to help the support guys but not the AssemblyInfo DLL versions now.

According to the Cap’n its not just the webpart dwp’s but lots of other features (small F)  that don’t like changes to AssemblyVersions, in fact there is code in SharePoint that deliberately IGNORES policy files.

So there you have it, again Versioning is a bit dodge in Scarepoint. Choose when to do it and know what the effects will be.  And don’t forget to take those *’s  (stars) out of the AssemblyVersion attributes and FIX it to 1.0.0.0.

However you can change the Feature.XML file and change the Feature versions this doesn’t have any effect that we have noticed.

Im thinking of throwing together a feature that reads all installed features (hidden or not) and displays the details like title, description and version.

Technorati Tags: ,,
Categories: Uncategorized Tags:

SPUtility.SendEmail Function truncates text

February 10th, 2009 No comments

It would appear that

SPUtility.SendEmail function truncates the body of the email.   I’m having this problem and so is someone else (here).

Not much more to add here, if anyone knows why or knows of a setting, love to here it

(please don’t post a workaround solution using .Net objects we can all figure that one out for ourselves thanks.)

Word of the day.

Damn.

Technorati Tags: ,
Categories: Sharepoint Tags:

WSS – CAML and XSD schemas

February 10th, 2009 No comments

If you developing List Schemas drop what your doing and go and install this.

CAML.NET.Intellisense

It is an expanded wss.xsd file containing a lot of descriptions and possible default values. When coding in Visual Studio using this will alter the schema defs and give you uber intellisense on your schema files.

If you already use wss.xsd in Visual Studio you will need to remove your reference.

Now if you forgot how you did that then the usual way I found of configuring it was to goto

C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas

(or equivalent for your platform)

An to create a file called wsscatalog.xml, you may have called it something else but it contains xml like this

   1: <SchemaCatalog xmlns="http://schemas.microsoft.com/xsd/catalog">
   2:   <Schema href="%CommonProgramFiles%/Microsoft Shared/web server extensions/12/TEMPLATE/XML/wss.xsd"
   3:           targetNamespace="http://schemas.microsoft.com/sharepoint/" />
   4: </SchemaCatalog>

 

So go and remove that before installing this version as it won’t remove it for you and Studio can fight over things if you don’t or just not work at all as was my case.

Categories: Sharepoint Tags:

WSS – ListView / Schema.xml and Embedding Javascript

February 9th, 2009 No comments

Many of you out there in SharePoint land will from time to time have the need to edit a list definitions schema.xml file to create your custom list.  You may also have need to edit the List View in that schema file to create a different kind of view, one not possible to create by the SharePoint UI.

I have had need to do this recently.  I needed a List View that highlighted expired items or tickets in my list.  It needed to make them go red.

Now you might think that’s easy enough create a calculated field that does date maths on the date you have in the list item and the current date that gives basically 1 or 0 for expired or not.  Well you’d be wrong.  You see you can’t use [Today] or anything like it in a calculated field the list wants fixed not dynamic values in it and will not allow Dynamic values, think about it, it would seriously effect performance.

Rather than create a DataViewWebPart based on my list view and edit that to death, it did not give me exactly what I required, even with editing, and the time to do it would be longer for me to achieve.  I decided to embed Javascript code into my ListView.

Read more…

Categories: Sharepoint Tags:

WSS SharePoint and Powershell

February 6th, 2009 No comments

This is just a quick note to ask the question

Are you using Powershell when developing your WSS application ?

Cos if your not your missing a trick.

Read more…

Categories: Uncategorized Tags: