Using stsadm to deploy, upgrade, update InfoPath Forms Templates with Managed code behind

This post talks about using stsadm and batch scripts to deploy InfoPath form with code behind which usually is called as InfoPath forms with managed code or the InfoPath forms managed templates.

The problem: If it’s just a couple of InfoPath forms with simple code behind we can deploy the form using the InfoPath Forms Client application itself. As laid out neatly here. To summarize, it involves the following steps:

  1. Publish to a network location
  2. Verify its browser compatible while uploading to InfoPath managed templates in Central Admin.
  3. Upload to InfoPath managed templates found in Central Administration
  4. Wait for the status to upload complete.
  5. SharePoint admin should activate it for a particular site where the developer want to use it.
  6. Wait for the activation to complete.

Imagine doing all this every time you make change to the code behind of the form or change the user interface. The worst part is waiting for the status to get completed as SharePoint does those kind of jobs based on the timer job service. To run these tasks forcefully the stsadm’s execsrvcjobs command operation comes handy.

Below is the script to install a new infopath form template and activate for a particular site collection:
::Publish the form to a location lets say it is published at C:\InfoPathForms\Publish\sample.xsn
cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
::uncomment the below three lines if you want to uninstall and re-install the infopath form template
::stsadm.exe -o DeActivateFormTemplate -url http://demosite -filename ::C:\InfoPathForms\Publish\sample.xsn
::stsadm.exe -o RemoveFormTemplate C:\InfoPathForms\Publish\sample.xsn
::stsadm.exe -o execadmsvcjobs
stsadm.exe -o verifyformtemplate -filename C:\InfoPathForms\Publish\sample.xsn
stsadm.exe -o UploadFormTemplate -filename C:\InfoPathForms\Publish\sample.xsn
stsadm.exe -o execadmsvcjobs
stsadm.exe -o ActivateFormTemplate -url http://demosite -filename C:\InfoPathForms\Publish\sample.xsn

Below is the script to upgrade or update the existing infopath form template for a site collection:
cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
stsadm.exe -o DeActivateFormTemplate -url http://demosite -filename C:\InfoPathForms\Publish\sample.xsn
stsadm.exe -o verifyformtemplate -filename C:\InfoPathForms\Publish\sample.xsn
stsadm.exe -o UpgradeFormTemplate -filename C:\InfoPathForms\Publish\sample.xsn
stsadm.exe -o execadmsvcjobs
stsadm.exe -o ActivateFormTemplate -url http://demosite -filename C:\InfoPathForms\Publish\sample.xsn

UPDATE: If you just changed the code behind of the form and want to deploy it there is even better and quicker way to do it. When the form is deployed using the above stsadm scripts what it does is, it depoys the form as a content type feature and the folder name is some what like FT- which is found under C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\
Under this you will find folder liek solution.xsn.1.0.0.210.1.0.0.210. Find the latest one and drop the updated DLL’s in there and then reset the IIS or recycle the app pool for the site collection. That is it!!

PS: I got the initial help of preparing the batch script from here.

15 Responses

  1. Thanks for the info. While this works well, it would not work for form templates that are associated with a custom workflow. The only way I have found the update a form is to redo the feature.

  2. […] whole process is long and gruesome if we have to repeat for many forms so I posted some time back on how to use stsadm.exe script to upload/delete/update the managed form templates. […]

  3. I get object reference not set to an instance of an object.

  4. Hai All,

    Infopath forms with managed code behindd can be published from the Central Admin.Complie the solution file,and place it in the same folder where the form is published,and when the form is uploaded in the Central Admin and activated it automatically create it as a feature in the features folder eg:(C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\FT-01-064abfd8-9833-3027-a083-a39d18a54cb5\solution.xsn.1.0.0.8) under which the solution.xsn and the application dll are located.if the dll is not copied you can manually copy the dll and reset the iis or reset the app pool,thi swill solve the issue.

  5. Good post. I am still getting the following error when I tried to activate the form from CA – see below.


    The form template could not be activated to the following site collection: http://mysitecollection:62000. You do not have the permissions required to perform this operation. Only the administrators of this site collection can activate to the site collection. Either add yourself as a site collection administrator, or have a site collection administrator activate the form template”.
    The port number is a part of site collection name.

    The form relies on one webservice and I am the site collection admin.

    Any ideas?

    • Chriss… I would try troubleshooting this as follows: Making sure the login you are using with central admin is also the admin for the site collection for which you are activating the form. Verify the form is compatible with the site collection. If u think web service data connection is the issue, you can just remove that data connection and its dependencies and try deploying the form. Also, dont forget to check the eventviewer logs.. As per error message, even you have proper permissions you should never have problems… As a final resort, 12 hive logs for any more info.

  6. […] Using stsadm to deploy, upgrade, update InfoPath Forms Templates with Managed code behind. Fuente: Blog de Srinivas Varukala. En este caso, el artículo describe como automatizar la publicación de un formulario utilizando STSADM. […]

  7. […] Using stsadm to deploy, upgrade, update InfoPath Forms Templates with Managed code behind. Fuente: Blog de Srinivas Varukala. En este caso, el artículo describe como automatizar la publicación de un formulario utilizando STSADM. […]

  8. […] to My Blog Welcome to John Eugene’s Blog. Recently used links. Installing/Upgrading/Deleting InfoPath forms Info path installation Trouble Shooting Possibly related posts: (automatically […]

  9. this article helped me get my Forms deployed, as I was receiving Access denied errors when I tried deploying using Central Admin.

    Also, good tip about just dropping in updated Dlls into the 12 hive, however I have live users, so cant reset IIS or the App Pool.

  10. […] Using stsadm to deploy, upgrade, update InfoPath Forms Templates with Managed code behind March 2008 10 comments 5 […]

  11. Hello,

    Thanks for this post. I think there is just a litle mistake in the following line :
    ::stsadm.exe -o RemoveFormTemplate C:\InfoPathForms\Publish\sample.xsn

    Should be :
    ::stsadm.exe -o RemoveFormTemplate -filename C:\InfoPathForms\Publish\sample.xsn

  12. Dear Srinivas,

    We are trying to upload a Infopath form Template using powershell & what we notice is when running the CMD Install-SPInfoPathFormTemplate -Path “:\Form.xsn”, after the internal verification process we get ” Conversion App DomainSponsor:Renewal() has no renewals left;failing to renew” from the ULS logs under “powershell.exe” category. After this nothing hapens and the CMD is kinda “stuck” even after 4-5 days of initiating it.

    We tried restarting the server and trying the same, but still face the same issue.

    Any thoughts on the same would be appreciated.

    Best Rgds,
    SSP

  13. Wow, fantastic blog layout! How lengthy have you been running a blog for?

    you made running a blog glance easy. The whole look of your site is great, as smartly as the content material!

  14. Hello! My name is Melvin Frizzell and I live in Brielle,NJ. I have read your blog post about Using stsadm to deploy, upgrade, update InfoPath Forms Templates with Managed code behind | Share Notes – All about Sharepoint Office System, .Net and I want to say that I am quite impressed with your professionalism on the subject!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: