Monday, 28 December 2015

C# SharePoint Content Type Visible on New button




Problem

When using C# and the SOM API in SharePoint 2013 to add new content types to a list, you find that the new Content Types are not appearing in the "New Item" ribbon button:


 
You could go to the list settings and simply select the "visible" property for the new content types but if you are doing this as a SharePoint feature then using the UI is not an option.
 
You would expect that the SPConentType class would have a "visible in new item" property but it doesn't. There is a "hidden" property but this particular property doesn't make the new Content Types visible on the ribbon. And as they say "therein lies the problem".
 

Solution

The first thing you have to do is recover from the fact that the SharePoint 2013 SOM API does not have a "visible in new item" property (even though we know it should). So how then does the SharePoint UI do this?
 
Well I don't know because I do not have the source code to the SharePoint UI (rhetorical question).
 
After some searching I found a few articles on this topic and they suggested that "reordering the content types" would solve the problem.

I found that the UniqueContentTypeOrder collection must first be nulled then the desired content types added back into it (this isn't exactly reordering, but close enough). This is the collection in question:

 
SPList.RootFolder.UniqueContentTypeOrder
 
Doing this is effectively the equivalent of using the UI on the list settings to reorder the content types and set the Visible property: 
 
 
 So without further adieu some trial and error lead to this solution:
 


 

 
 
 
 
 
 
 



 

Sunday, 15 March 2015

Powertech 5 in 1 manual

Powertech 5 in 1 manual



Seems like the manual for this powertech 5 in 1 power supply is hard to get on the internet as of March 2015, so here it is... the first online version:

Powertech 5 in 1 manual

Its handy for looking up the charge time which is 34 hours (or 48 hours if its the first charge).

The jump start instructions are also important as they remind you that the black negative cable must never be connected to the battery. Instead, first connect the red positive cable to the positive terminal on the car battery, then clamp the black negative cable to a non moving metal part of the vehicle. When disconnecting do it in the reverse order by disconnecting the black negative terminal first, and then disconnect the red negative terminal.

Its best to read the manual before you attempt any connections you are not sure about.