Customizing a Survey

You boffs out there will recognize the pains of providing a quick POC for a customer requirement without developing a fully fledged solution. Ok so here goes. You wanna provide customization to a survey without going full code. For example, in my requirement (Office 365 Implementation), I wanted to add a ‘response’ column to a survey which does not behave like a normal list (naughty naughty!) . This column would store a response to the answer to the survey by means of a workflow on that survey. (There was only one question in the survey as the answers needed to be anonymous and this is near impossible without full code to any list because of the default columns: Created by and Modified by). So the user answers that one question, the workflow kicks off to collect feedback from the manager or approved person who can respond to it, and then the workflow fills the response column of the survey with the response . Simples hey? lol

Ok So here are the cheats for customizing a survey:

Create New View:

  • Open the new view page of any list in your SharePoint site, and copy the URL to a notepad.
  • Open  survey settings page, and from the URL copy the List ID. (List=%7Bxxxxxxxx%2Dxxxx%2Dxxxx%2Dxxxx%2Dxxxxxxxxxxxx%7D).
  • Replace the list name to the last of the URL with the survey list name.

Copy the modified URL to a new browser window, and you are done, you will be now in the ‘Create View’ page of your Survey List. Create the view as you wish here……….

Create A New Column:

Same the way you did for survey view, copy the new column page url (/_layouts/fldNew.aspx?ListID)

  • Replace the ListID with the survey list ID and you are done.


Modify View:

  • In order to perform the modify view of the newly created view as per the steps above, just add your list as a webpart to any SharePoint page.
  • In the modify shared webpart option, select the view which you want to edit in the Selected View and  select the option ‘Edit the current view’.

As with all hacks, save a copy in case you break anything and regularly back up your servers. If you’re on Office 365, Microsoft got your back!


Content Organiser and Workflow Fix

I have been looking at using the new Content Organizer feature in SharePoint 2010. The idea being that when people upload or ‘Send To’ a document center, the document is routed to the correct location.

When I enable the Content Organizer feature on my site, the ‘Drop Off’ library is created.

I then create a rule to route the document to the ‘Documents’ library. I don’t want the document to be published and visible to all users until it has been approved. So I create a simple Workflow to do approval which should start when the document is created.

Unfortunately, the workflow never starts automatically once Content Organizer has been enabled.

I had a look at the Content Organizer code with Reflector, and it seems to be executing a SystemUpdate after it has moved the document to the correct location. I assume it is running this as one of the service accounts. (I have not checked which one).

When I look at the ULS logs in more detail, I see the following exception is occurring when I upload a document.

“Declarative workflows cannot automatically start if the triggering action was performed by System Account. Canceling workflow auto-start.”

I tried submitting the document as a user other than System Account, but the error persisted.

So I decided to look at starting the workflow programmatically. I created an Event Receiver is Visual Studio 2010.

I found this post from Tobias Zimmergren with some sample code to programmatically start a workflow.

I overrode the ItemAdded event as follows:

public override void ItemAdded(SPItemEventProperties properties)
//SPListItem item = properties.ListItem;
//item[“Title”] = ” ” + item[“Title”] + ” – added ” + DateTime.Now;

if (properties.ListItem.ParentList.TemplateFeatureId==new Guid(“00bfea71-e717-4e80-aa17-d0c71b360101”))
SPWorkflowManager wfManager = properties.ListItem.ParentList.ParentWeb.Site.WorkflowManager;
SPWorkflowAssociationCollection wfassociationCollection = properties.ListItem.ParentList.WorkflowAssociations;
foreach (SPWorkflowAssociation wfAssociation in wfassociationCollection)

if (wfAssociation.BaseId == new Guid(“8ad4d8f0-93a7-4941-9657-cf3706f00409”))
wfManager.StartWorkflow(properties.ListItem, wfAssociation, wfAssociation.AssociationData, true);


I got the baseid for the WorkflowAssociation using SharePoint Manager:

I run the event receiver by pressing F5 in Visual Studio and watch the behaviour.

When I upload the document, the content organizer routes the document to the folder in the library and the workflow starts.

I expect to spend some more time refining the code for the eventreceiver to make sure it only executes under the right circumstances, but thought I would share in case anyone else is experiencing the same issue.


Content Organiser and Workflow Bug In SharePoint 2010

SharePoint 2010 introduced a new feature “Content Organizer” to organize your content automatically, based on custom-defined rules. However, these rules add new entity to the hierarchy of events that can be executed for the List items, and this execution order is not well documented. It’s important to understand the sequence to process documents accordingly.

For example, when the user uploads his CV to the library you want to add watermark by Workflow, update .docx metadata with event receiver and round document to “unprocessed” folder using content organizer. We have “DropOff Library” with WorkFlow, EventReceiver attached and with Content Rules. The default execution sequence will be the following:

  1. WorkFlow
  2. Event-Receiver
  3. Content Organizer Routing Rules

PS: Take into account that WF/EventReceiver sequence can be changed programmaticaly, using Sequence property of SPList.EventReceivers, but when you reconfigure Workflow it always gets the first order in execution

PPS: Content Organizer Routing Rules impersonates the Application Pool account, thus in might perform actions under “System Account” and your destination folder’s WorkFlow will not start.