Tuesday, September 11, 2012

SharePoint 2013 Preview Popup Menus Missing

After re-installing SharePoint 2013 Preview to fix an issue on a test server, I found that the popup menus (such as the settings menu at the top right corner) did not work in IE9. Those areas did not change background colour, either, when hovering over the location. Yet they worked in FireFox! Eventually I removed the server name from the local intranet zone in IE - and the menus started working again. Tried replicating the issue by adding the URL back to that zone, but can't get it to happen again. Beware!

Tuesday, January 17, 2012

HTML5 Learnings - Getting IE9 to Accept Canvas Elements

Working with HTML5 at the moment is a lot like the "good old days" of designing pages to work in IE, then redoing the page for Navigator (oooh, showing my age in the industry there!)

Anyhows, today's little lesson was about a small subtly in IE9 behaviour when handling a page incorporating Canvas elements. Initial I was working on the page in Web Expression, and viewing the page via a "file://..." path in the IE9 address bar. All was fine, and the JavaScript rendering the canvas element content worked OK.

But then I copied the HTML into a page being served up through IIS, and accessed via an "http://..." address. Looking at this new page, IE9 now tells me that the canvas element is not supported (modernizr adding the "no-canvas" class to the html element). Weird. Much playing later, found that it is necessary to add the following header metatag to the page:

<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>

Seems that IE treats pages accessed from the file-system differently that those from an http address!

Wednesday, January 4, 2012

Setting BCS Secondary Fields Programmatically in SharePoint 2010

Phew, that was quite a battle. I have been writing some code to import values from a CSV file into some custom lists in SharePoint (I realise that there are, of course, plenty of other ways to import into SharePoint, such as using PowerShell or a third party app., but specific needs call for special handling), and one of the requirements is to import data into External Columns in the SharePoint list.

Original this process used the GetSecondaryFieldNames() method of the SPBusinessDataField instance to get the internal names of each of the secondary fields, and then combined each of those with the internal name of the SPBusinessDataField to create the displayname value for each secondary field. The list item fields could then be set using these displayname values.

This worked fine in the dev environment... but of course the real workd is different! Researching the failure of this process on the target machine showed that the display names for the secondary fields did not contain the values from the GetSecondaryFieldNames() call (PowerShell allowed me to easily view the Schema XML for the fields in the list, saving the need for a tool like SharePoint Manager).

So, my solution was to seek the secondary field by enumerating through all fields in the list, seeking the field whose:
  • "DisplayName" property value starts with the internal name of the related external data field
  • "BdcField" property value matches a string value returned by GetSecondaryFieldNames()
This lets me find the required secondary BCS field, and gived me the GUID for use in later populating that field with a value. I then make sure to cache this GUID, meaning on the next pass through this part of the code I can use the cached value rather than re-enumerating all the fields once again.