Archive for September, 2007

Add an event handler

I keep using this snippet of code:

if( window.addEventListener ) {
window.addEventListener("load", fn, false );
} else if( window.attachEvent ) {
window.attachEvent("onload", fn );
}

It’s just a tidier way of attaching a function ‘fn’ to an event. It also allows multiple handlers per event. There could be another ‘else’ where we just assign the function to an event (e.g. window.onload = fn ) but that would only support one handler per event.

The registry and "Word could not create work file"

I had an interesting problem earlier this week. I had a MOSS VM that seemed to work okay, except whenever I tried to create a document using the template on a Document Library. Then I would get the error:

Word could not create work file. Check the temp environment variable.

Okay. So I did - and the temp variable was just fine. Odd, I thought. Eventually, after digging through news groups and so on, I found a suggestion to check parts of the registry. Well, actually, one of my colleagues found it. The value in the key

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\cache

was wrong - it pointed to an invalid directory. Not sure why, but I’d been monkeying around with some stuff which could’ve mucked it up. Anyway, fixed up the filepath in that key, and it was fine - I could create documents from Document Library templates.

SharePoint Folders Ending in _FILE

Here’s an interesting thing a colleague noticed - SharePoint folders with names ending in _FILE are renamed to end in _FILE_. In the image below the names and titles were the same when I typed them in:

Notice the line for A_FILE. Name and title are now different. No idea why that happens. I’m guessing that SharePoint uses folders with a suffix of _FILE for it’s own internal stuff…

Joel Oleson and Disk allocation in SharePoint

Was just asked about this and Joel’s post made my day much easier. What discs in what configuration is an important subject for any server - there’s plenty of performance to gain here for fairly little effort.

SharePoint Skinner

Themes in SharePoint are tough. I think this quote describes it nicely:

If you have attempted to override the styles on an out of the box SharePoint site, you know that it isn’t a very easy thing to do. The core.css file that contains the basic rules has 979 different style rules.

The core.css file uses a palette of 132 colors and 143 images.

The default page of a newly provisioned team site uses only 61 of those rules.

So, unless you have branded a lot of SharePoint sites and are intimately familiar with core.css and the default master pages and page layouts, just figuring out where to start modifying can be a daunting task.

So Doug has built SharePoint Skinner to make that easier. I’ve not tried it (yet) but I like his thinking…

Workflow Correlation tokens

I just found a post where someone had gotten confused about tokens in MOSS workflow:

  • Workflow Correlation Tokens are used to identify the Workflow an event should be routed to.
  • Task Correlation Tokens are used to identify the Task in the workflow the event is about.
  • Each task must have its own token.
  • A workflow token should never be used with a Task.

Error: The event receiver context for Workflow is invalid

This is an obscure error:

Error in commiting pending workflow batch items: System.InvalidOperationException: The event receiver context for Workflow is invalid.
at Microsoft.SharePoint.SPEventReceiverDefinition.ValidContext()
at Microsoft.SharePoint.SPEventReceiverDefinition.ValidReceiverFields()
at Microsoft.SharePoint.SPEventReceiverDefinition.

GetSqlCommandToAddEventReceivers(IList`1 erds)
at Microsoft.SharePoint.Workflow.SPWinOESubscriptionService.

CommitNewSubscriptions(Transaction txn, IList`1 erds)
at Microsoft.SharePoint.Workflow.SPPendingWorkBatch.

ProcessWorkItemBatch(Transaction transaction, Work method, IList`1 workItemBatch)
at Microsoft.SharePoint.Workflow.SPPendingWorkBatch.

Commit(Transaction transaction, ICollection items)

Let’s skip over wondering what an erd is (event receiver definition maybe?)- the solution to this is simple, but not obvious. Check you have created properties for TaskID, TaskProperties and Correlation Token. I found this solution at Robert Bogue’s blog. As a side note it is a REAL pain in the ass that setting up TaskIDs and TaskProperties is so manual - or at the very least that tasks with unassigned values for these do not appear with the red ‘warning’ exclamation mark in Visual Studio.

Adding Snippets in Visual Studio

I keep forgetting how to do this, and have to do so every time I want to create a new SharePoint workflow.

  1. Open Visual Studio.
  2. Right click on toolbars and ‘Customize’
  3. Click ‘Commands’ Tab.
  4. Click on the ‘Tools’ category.
  5. Add the ‘Code Snippets Manager’.
  6. Add ‘C:\Program Files\Microsoft Visual Studio 8\Xml\1033\Snippets\SharePoint Server Workflow’ to your snippets
  7. It should be straight forward from there…

Comments from my old blog:

Are you using your own project templates? I’m curious because using the MOSS Workflow Project templates (both state machine and sequential)–the templates that come with the MOSS SDK–and I have the snippets already available to me.

Anyway, just throwing that out there.

By Peter {faa780ce-0f0a-4c28-81d2-3 at 17:30:01 Monday 10th September 2007

Nope, these are the ones out of the SDK. I’m not clear why, but in some VMs that I use the snippets aren’t immediately available after I install it. And normally the ‘Code Snippets Manager’ is already available too - but not always. I haven’t figured out what factor causes these things to occur :/

But yes Peter, you’re right - normally they should be available.

By Andy B at 11:16:21 Tuesday 11th September 2007

Excel Services - save a spreadsheet through the web interface…

There was me thinking that this wasn’t possible -You can save an Excel spreadsheet presented via Excel Services. Well, kind of. It’s prototype code, and unsupported, but still, that’s waaayyy cool. Now, all it needs is to work with check-in/check out or ‘last wins’.

Create a SharePoint Timer Service

More linkage - I know, quite a lot now - but this is stuff I’m sure I’ll want to remember later: Add your own Timer service by Andrew Connell

« Previous PageNext Page »