Tuesday, 12 March 2013

Sharepoint 2010: Increase workflow frequency in Powershell

My current project relies heavily on Nintex Workflow 2010 to process its workflows. The solution is littered with NWF files and I am generally at the mercy of the Sharepoint Timer Service about when to start the process.

I run the following script to increase the (default) frequency that the workflows are polled for work. It should be noted that although this is great for a development environment, but will probably cause more harm than good in a larger shared environment.
There may be some serious resource contention if 1000s of workflows are running every minute.

Anyway, on to the the script:

Write-Host "Setting workflow postpone threshold to 30"
Set-SpFarmConfig -WorkflowPostponeThreshold 30
Write-Host "Setting the polling frequency to evert minute"
get-sptimerjob | ?{$_.name -like "job-workflow"} | set-sptimerjob -schedule "every 1 minutes between 0 and 59"
Write-Host "Configuration Complete"

Tuesday, 5 March 2013

Windows 7 tools for capturing issues

It can be rather frustrating when a user tries (ineffectively) to explain a problem or the steps to reproduce it. I have found 2 fantastic tools that can make life a lot easier:

1. Snipping Tool - a build in image capturer that can be used to easily send screen shots (because Ctrl-PrntScreen is too hard)
2. Problem Steps Recorder - a tool to record the steps to reproduce a a problem. The days of issues being lost in translation or steps being left out are history.

If life was only about resolving bugs, software development would be a lot easier ....

Monday, 4 March 2013

Error 0x80070057 when using ProcessBatchData

I was recently using the SPWeb.ProcessBatchData function (more information here) when the following error code reared its ugly head:



The  XML looked fine, but there was a sinister problem at play. The UTF declaration was in lowercase INSTEAD OF UPPERCASE.

Thats three hours of my life I am never getting back. Oh well, live and learn (and share!).

Get the internal column name in Sharepoint 2010 from the display name

The internal column is easily obtainable from the Sharepoint object model.

A recent function required me to use the internal name instead of the (provided) displayname. The following function resolved the problem quickly and easily:

private string InternalName(string displayName)
 SPFieldCollection fields = SPContext.Current.Web.Lists["MyListName"].Fields;
 if (fields.ContainsField(displayName))
   if (string.Compare(displayName, "Title", true) == 0)
     return "Title";
     return fields[displayName].InternalName;
 throw new Exception("Column not found");

This function is not great, but it has solved my problem. The one caveat is the extracting of the 'Title' column. The function was returning 'LinkTitle', which caused the bulk update the fail quietly.

The hack fixed the problem. This is not my most elegant piece of code, but it does the business.