Programmatically update InfoPath form Content Type to open in browser

11 12 2009

If you are deploying an InfoPath form to your site as a feature then it is highly likely your form will be installed as a content type. By default however the form will try to open in the InfoPath client if there is one installed on the machine.

You could of course go into the list settings and change this so that new instances open in the browser but this is pain if you are trying to create an automated install/deploy process.

So how can I do this programmatically I hear you ask??

Well it turns out that the SPContentType class has a property called RequireClientRenderingOnNew. This is a boolean value which is by default set to ‘true’.

See the below code snippet on how to change this –

   1: SPContentType cType = web.ContentTypes["My ContentType"];

   2: cType.RequireClientRenderingOnNew = false;

   3: //Update the content type

   4: cType.Update();

The best place to perform this change would probably be in a ‘featurereceiver’.

Hope this helps 🙂