How to: Deploy a .UDCX file to a Data Connection Library

Posted Thursday, May 14, 2009 10:08 AM by CoreyRoth

The other day I saw that @mrackley was looking for a way to deploy a .UDCX file to a data connection library.  Having CAML still fresh in my mind from the talk Kyle Kelin and I did on Monday, I decided to see if I could get the job done using the Module and File elements.  Sure enough, I found a simple way to deploy the .UDCX file.  Here is what it looks like.  For the purpose of my example, I am going to deploy a file test.udcx to a data connect library at the /Data Connections path in my current site.  Adjust your paths accordingly.  I have a simple Feature.xml.

<Feature

    xmlns="http://schemas.microsoft.com/sharepoint/"

    Id="{CE871E99-B9E8-4b3e-AF2B-D715C8AD08F0}"

    Scope="Web"

    Hidden="False"

    Title="UDCX Deployment"

    Description="This feature deploys a UDCX file to a data connection library."

    >

  <ElementManifests>

    <ElementManifest Location="elements.xml" />

  </ElementManifests>

</Feature>

I then have an elements.xml file like the one below.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <Module Name="DataConnections" Url="Data Connections" Path="">

    <File Url="test.udcx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="FALSE">

      <Property Name="Title" Value="test.udcx"></Property>

    </File>

  </Module>

</Elements>

The Name attribute of the Module element really doesn’t matter, but the Url does.  Set this to the relative path of your data connection library.  I then use a File element and set the Url attribute to the name of my file.  Here you will notice I tried to set a property on the file and although it was not successful in setting the Title property of the form, simply having it there allowed the data connection library to properly read the file as a universal data connection file instead of an Office data connection file.

This is what my data connection file looks like.  It’s a simple file that controls where the submit action goes to.

<?xml version="1.0" encoding="UTF-8"?>

<?MicrosoftWindowsSharePointServices ContentTypeID="0x010100B4CBD48E029A4ad8B62CB0E41868F2B0"?>

<udc:DataSource MajorVersion="2" MinorVersion="0" xmlns:udc="http://schemas.microsoft.com/office/infopath/2006/udc">

  <udc:Name>SharePoint Library Submit</udc:Name>

  <udc:Description>Format: UDC V2; Connection Type: SharePointLibrary; Purpose: WriteOnly; Generated by Microsoft Office InfoPath 2007 on 2009-05-14 at 9:29:23 by MOSS-SERVER\croth.</udc:Description>

  <udc:Type MajorVersion="2" MinorVersion="0" Type="SharePointLibrary">

    <udc:SubType MajorVersion="0" MinorVersion="0" Type=""/>

  </udc:Type>

  <udc:ConnectionInfo Purpose="WriteOnly" AltDataSource="">

    <udc:WsdlUrl/>

    <udc:SelectCommand>

      <udc:ListId/>

      <udc:WebUrl/>

      <udc:ConnectionString/>

      <udc:ServiceUrl UseFormsServiceProxy="false"/>

      <udc:SoapAction/>

      <udc:Query/>

    </udc:SelectCommand>

    <udc:UpdateCommand>

      <udc:ServiceUrl UseFormsServiceProxy="false"/>

      <udc:SoapAction/>

      <udc:Submit/>

      <udc:FileName>Specify a filename or formula</udc:FileName>

      <udc:FolderName AllowOverwrite="1">http://moss-server/MyFormLibrary</udc:FolderName>

    </udc:UpdateCommand>

    <!--udc:Authentication><udc:SSO AppId='' CredentialType='' /></udc:Authentication-->

  </udc:ConnectionInfo>

</udc:DataSource>

Here is what it looks like once the feature was activated.

UDCX

As you can see the title field is blank but other than that it seems to work fine.  I’ll also point out that the file is automatically set to Approved status when uploaded this way.  Here are the properties.  You can see that it correctly picked up that it was a WriteOnly connection for a SharePointLibrary.

UDCX2

Kyle and I debated in our talk if CAML or the API was better for provisioning sites and what not on Monday night.  I certainly think this solution is a lot better than writing code.  It’s simple and very quick to implement.  The Module and File elements are very powerful and you can use them to deploy just about any kind of file.  I’d like to figure out how to get the Title field set properly, but it’s not a deal breaker for me right now.

Follow me on twitter.

Filed under: , ,

Comments

# re: How to: Deploy a .UDCX file to a Data Connection Library

Friday, September 18, 2009 7:29 AM by GuyO

This works well. - Until the connection is to a Sharepoint List. -- unlike column lookups in a sharepoint feature, infopath isn't smart enough to fix up a lists/foo reference.  I have been able to fix up the ListID Guid references using a featureEvent handler. I just finished testing the and deploying the solution and as soon as I can get it "cleaned" up for publcaton, I'll post the link,

# re: How to: Deploy a .UDCX file to a Data Connection Library

Tuesday, September 29, 2009 10:22 AM by GuyO

I just discovered another reason for doing all of this in CAML vs a feature handler -- MSDN Article 931414 -- it's not possible to update the title of a udcx file after it has been deployed; so it has to be done in CAML as shown above.

# re: How to: Deploy a .UDCX file to a Data Connection Library

Tuesday, October 6, 2009 9:38 AM by CoreyRoth

GuyO.

Actually I have discovered you can specify the list name for a SharePoint List in a .UDCX.  CHeck out this post.

www.dotnetmafia.com/.../specifying-a-list-by-name-in-a-udcx-file.aspx

# re: How to: Deploy a .UDCX file to a Data Connection Library

Tuesday, December 1, 2009 9:00 AM by Camilo Vergara

How can I fix the empty title issue?

# re: How to: Deploy a .UDCX file to a Data Connection Library

Tuesday, December 1, 2009 9:14 AM by CoreyRoth

I've actually run into the Title field not being populated before as well.  For some reason it doesn't pick it up from the CAML.  However, it does not affect the usability of the .udcx file.

# re: How to: Deploy a .UDCX file to a Data Connection Library

Tuesday, March 23, 2010 10:18 AM by Pascal van Alphen

The Title field not being filled does matter. If you change or upload a new version of a UDCX to the Data Connection Library, and then want to Check In that file, SharePoint doesn't allow it: the Title is a required field. This check is ignored with feature activation, but not with a manual change.

Most annoying thing about this: manually entering the Title doesn't seem to work either.

# re: How to: Deploy a .UDCX file to a Data Connection Library

Wednesday, August 25, 2010 5:26 AM by n0ext

Download the .udcx file, delete the sharepoint one and upload the previously downloaded back. You can now specify the Title and do the Check-In (you could also modify the file parameters such as the connection string if necessary).

# re: How to: Deploy a .UDCX file to a Data Connection Library

Tuesday, October 5, 2010 5:32 AM by shakir

Hi Corey

I want to set up the filename

<udc:FileName>Specify a filename or formula</udc:FileName>

as value of my control in infopath,

i am deploying the infopath form through central admin,

# re: How to: Deploy a .UDCX file to a Data Connection Library

Friday, September 30, 2011 4:51 AM by Tim Coalson

Thanks for sharing.  I used the information you provided in conjunction with this article spmasters.blogspot.com/.../how-to-deploy-udcx-file-to-data.html to deploy the udcx file and then update the contents with the appropriate ListId and WebUrl.

# re: How to: Deploy a .UDCX file to a Data Connection Library

Wednesday, November 30, 2011 9:23 AM by Chris Wininger

I really wish I could figure out the title issue. It is not specific to the deployment method described above. I have a connection library that drops the titles regardless of whether you deploy from SharePoint, through a feature receiver, or through elment.xml. I have tried specifying the title in the caml and altering it through code. It just stays blank. You can delete the file and re-upload, but that defeats the purpose of designing a feature. I do not want to have to manually create every connection. The missing title does cause problems because it prevents future updates to the file. I've seen lot's of people with this issue, but no solution. Just the suggested work around of deleting the file and re-uploading it. If anyone has a real solution that will allow me to add udcx files without manual intervention I would be very greatful.

Leave a Comment

(required)
(required)
(optional)
(required)