Programmatically update InfoPath form Content Type to open in browser

Programmatically update InfoPath form Content Type to open in browser

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 -
[code lang="csharp"]
SPContentType cType = web.ContentTypes["My ContentType"];
cType.RequireClientRenderingOnNew = false;
//Update the content type
cType.Update();
[/code]

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

Hope this helps :-)

UDH7UPSSP9QQ

3 thoughts on “Programmatically update InfoPath form Content Type to open in browser

  1. AB

    I have the exact opposite problem. I have a form with custom code and I want it to open in the IP client. All users have InfoPath installed. Unfortunately, the behavior is inconsistent and it opens for some in the client fine but fails for others via a link.

    Where do I double check for the snippet you have above?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">