Friday 21 June 2013

SharePoint 2013 - Custom Field Type Controls - How can I use the JSLink Property for Rendering in the List View, but still Use Server Controls (e.g. Telerik Controls) for Edit and Display View?

You may know that in SharePoint 2013, you can now control how a field renders completely by using JavaScript via the new JSLink Property on field controls. An example of this can be found on MSDN at "How to: Extend the Geolocation field type using client-side rendering". What if you want to do JavaScript rendering for just the list view - and use fully featured controls for editing and item display?

This is not documented anywhere (I found this by trial and error and some help from .NET Reflector - - but you can actually have both the JSLink render your field in your SharePoint list view and take full advantage of server rendering of controls (e.g. using Telerik AutoComplete for Token Selection) at the same time.

You can do this by overriding the JSLink property in your Field class (inheriting from SPField) as below so that it renders your full controls for Display/Edit and renders your JSLink for viewing in a list:

   public override string JSLink
                if (SPContext.Current != null && SPContext.Current.FormContext.FormMode == SPControlMode.Invalid)
                    return "../_layouts/15/MyProjectName/CustomFieldControl.js";
                    return string.Empty;
                base.JSLink = value;

As above, this looks at the current SPContext to determine whether it is currently rendering in the list view (and renders the JSLink property) - otherwise, it just uses the default server control rendering behaviour.


SharePoint 2013 - Why do my Custom Field Type Controls Seem to be Cached and keep Loading Up An Old Version? Some Gotchas for SharePoint Custom Field Types

When creating custom Field Types in SharePoint 2013 (see for examples), there are several steps you need to take to register it with SharePoint. These are all convention-based.

  1. You must create a file called fldtypes_MYFIELDNAMEField.xml e.g. fldTypes_ParentField if you want to add a field called "Parent". SharePoint will pick this field up based on this naming convention for your file.
  2. You need to deploy a user control (e.g. ParentFieldControl.ascx) to the SharePoint HIVE Control Templates directory (it will not work in a subdirectory).
  3. Within the ascx files, you should Specify a rendering Template like so:
<SharePoint:RenderingTemplate ID="ParentFieldControl" runat="server">
        <div class="customFieldType">
        <telerik:RadAutoCompleteBox runat="server" ID="autoCompleteTextBox" CssClass="customFieldControlParentGroupList" Filter="Contains" DropDownHeight="400" DropDownWidth="375" InputType="Token" Delimiter='<%# Constants.DefaultDelimiter %>' DataTextField="Text" ToolTip='<%# DataBinder.Eval(Container.DataItem, "Description")%>' DataValueField="Value">

Problem is, I did this and deployed my solution and my changes were not being propagated when my updated custom field was rendered within SharePoint. I tried a few things:

  1. Deleting the field from all lists and the Site fields collection in SharePoint with SharePoint Designer and/or the free tool SharePoint Manager 2013
  2. Removing the Custom Field
  3. Rebooting
Yet my changes weren't being reflected when I deployed the new version. What was going on? Was it some kind of weird caching that persisted between reboots?

What is not clear from the documentation is that the Rendering Template Id MUST be unique between all controls that you deploy as a custom field type. I was REUSING the same DefaultTemplateName and DisplayTemplateName between all controls (following the DRY principle).

I originally thought that it was loading up my control based on the NAME of the ascx control e.g. fieldTypes_ParentField would (by convention) load up the ParentFieldControl.ascx file to perform rendering for that field. This is NOT the case. Instead, the when you override the "DefaultTemplateName" or "DisplayTemplateName" properties on "Microsoft.SharePoint.WebControls.BaseFieldControl", you must ensure that these values have not been used elsewhere by custom fields in your project - otherwise SharePoint will keep picking up the first control it finds with a matching "DefaultTemplateName" or "DisplayTemplateName".

Now because I was reusing the same Template Name between all controls within my ascx files, it was rendering the first control it happened to find - without throwing an exception!

Be warned.


Thursday 13 June 2013

Outlook 2013 Bug when using IMAP - Beware the Bandwidth Blowout!

We recently had issues with our work internet connection that meant sizeable amounts of data were being chewed up without our users doing anything in particular or untoward.

Using the bandwidth monitor utility Networx ( (which breaks accumulated traffic down by process), we specifically found that Outlook 2013 was downloading large amounts of data (40-50MB) - many (but not all) times that a "Send and Receive" synch was performed. This was using IMAP running against the open source DoveCot ( as a mail server.

Now by default, this is set to every 30 minutes. If a machine is on 24 hours day, this can add up to 2.4GB per user - which clogs up your network and really adds up on anything but an unlimited plan!

Cracking open Wireshark (, I turned off SSL to see what was going on in terms of the IMAP commands going down the wire and the full extent of the download. Nothing stuck out apart from the fact that setting the "Mail to keep offline setting" to 24 months as below performs an IMAP "UID SEARCH SINCE 13-Jun-2011" to filter results. This is as expected.

To my surprise, with the default "All" Setting for "Mail to keep offline", you can also see that on regular but apparently random occasions every single email (including ALL content and ALL binaries) was being downloaded every time from the mail server - regardless of whether Outlook already had a locally cached version or not. Sometimes, the download will only be 5MB per click of "Send and Receive All". I tried to reproduce it and it tends to happen when you save Drafts or send/receive large items in your inbox - but I wasn't able to isolate the issue through a process of elimination.

This may well be part of the OST corruption issues mentioned here - the IMAP issues in Outlook 2013 are apparently high on the MS internal support agenda:!topic/gmail/9alMlaOkMC4

In terms of the mail server, the installed version of Dovecot also seems to support LIST-EXTENDED for special folder support introduced in Outlook 2013 - so that doesn't appear to be the problem (unless there is a variation on the standard between Outlook/the IMAP server - which is not impossible).

So no clear conclusions I'm afraid. The one thing that is clear is that there are problems with Outlook 2013 and IMAP - based on the large number of problems I've seen floating around the web. The above problem is just one example of these. I've also seen that Outlook 2013 sometimes doesn't download new emails at all (even though other clients such as Android download from the same mail server correctly.). In addition, when working with drafts and saving the draft email repeatedly, Outlook will not be able to save it and say that it must be saved as a new copy within your Drafts folder.

Apparently, a fix to some of these problems should be released around August 2013 (as per!topic/gmail/9alMlaOkMC4)

In the meantime, to fix the heavy bandwidth usage issue, I can only suggest:
  1. Roll back to Outlook 2010 if you're using IMAP . This seems to be a popular option - although you cannot have Outlook 2013 and 2010 running simultaneously (unlike other MS Office Products).  [Recommended - this worked in my situation and reduced synch bandwidth usage from 50MB to 850KB]
  2. Perform a full initial synchronisation with the default "All" setting. Then reduce your "Mail to keep offline" time window to a smaller figure after this initial synchronization (e.g. 1 month) 
  3. Delete your local OST file and set up email again. This may give you temporary relief from the problem - but it wasn't a permanent fix for me.
  4. Use yet another client like Thunderbird - although this apparently also has issues with non-appearing folders with some IMAP providers as well.
  5. Reduce your synchronisation frequency (to something less than 30 minute full synchs). 
  6. Update your mail server if possible to ensure full compliance with standards. This isn't an option for me. You should also confirm this with a pilot/Proof of Concept to confirm that it fixes your specific issue.
  7. Clean out/auto-archive your emails!


Saturday 1 June 2013

DDK's Trip to Singapore and Malaysia 2013 - "The All-You-Can-Eat Chilli Crab and Stingray Event"

We just returned from our trip to Singapore and Malaysia after a particularly long and arduous flight back. There wasn't time for rest at all and we spent most of the time on our feet! Some of the more memorable events of the trip:
  1. Swimming on top of the Marina Bay Sands Hotel ("aka The Sands SkyPark") in their Infinity Pool - 59 Levels above the city. The feeling of floating above the city was a little disorienting at first. The spa also had spectacular views out to the 100+ ships at sea off the coast of Singapore.

  2. The light shows at Gardens By the Bay were quite spectacular (i.e. the kids loved it!).

  3. Visiting The Sentosa Island (Singapore) Adventure Cove Water Park - which has a river run that takes you around the park and through tanks of Stingrays and Sharks along the way. The obstacle course, the snorkel pools and wave park were also quite good value for the kids.

  4. Getting hungry after that and eating some Stingrays in the food market in Kuala Lumpur in Malaysia.
  5. Zach being sick on the floor of KL airport twice just before boarding closed - and then having the 300 people on the plane wait for a quarantine inspector at Sydney Airport so they could inspect him for avian flu.
  6. Trying some real Singapore Chilli crab and "Monster Fish" - one of the spiciest fish dishes I've ever had (and I lather tabasco on most meals normally). Kids were also impressed with my ability to suck out fish eyeballs - what a delicacy! The sweet Coffee Tapioca (covered in Coconut) and Taro breakfast treats were also an excellent start to a day on the road.
  7. Walking up the 272 steps of the Batu Caves and seeing the massive Gold Murugan Statue at the base of the steps. The light filtering through the roof of the caves creates a wonderfully magical atmosphere when standing inside.

  8. Singapore Slings @ Raffles Hotel that gave Lisa a big hangover that she is still recovering from!

  9. Going up the Petronas Towers - towering 452 metres above Kuala Lumpur.
  10. Heidi going on the Genting Highlands Horror ride in Malaysia. She said it was "so boring" at the start and was crying by the end of it. Zach loved the whole ride and wanted to shoot more werewolves and zombies by the end of it. This distracted him from the fact that he had just received a massive bump in the middle of his forehead that (even after copious amounts of ice) made him look like a mini-unicorn.
  11. The crazy bathrooms in the Star Hill Shopping Centre in Kuala Lumpur - all made of piled slate. There was a man who would pump an old waterwheel when you needed to wash your hands. A bit creepy I have to say. Zach got a fright and insisted that the man only had one arm. Crrreeeeepy!

For more pictures of our holiday, see