Specifying a list by name in a .UDCX file
Posted
Monday, October 5, 2009 4:07 PM
by
CoreyRoth
I’ve been working with InfoPath again lately since I’ve been working with Document Information Panels and I thought I would share another quick tip today. Observe the following .UDCX file.
<?xml version="1.0" encoding="UTF-8"?>
<?MicrosoftWindowsSharePointServices ContentTypeID="0x010100B4CBD48E029A4ad8B62CB0E41868F2BF"?>
<udc:DataSource MajorVersion="2" MinorVersion="0" xmlns:udc="http://schemas.microsoft.com/office/infopath/2006/udc">
<udc:Name>list_2F9fb67e-ab7d-44b7-accc-d9f6c9ca37f9</udc:Name>
<udc:Description>Format: UDC V2; Connection Type: SharePointList; Purpose: ReadOnly; Generated by Microsoft Office InfoPath 2007 on 2009-10-05 at 15:02:14 by MOSS-SERVER\moss_setup.</udc:Description>
<udc:Type MajorVersion="2" MinorVersion="0" Type="SharePointList">
<udc:SubType MajorVersion="0" MinorVersion="0" Type=""/>
</udc:Type>
<udc:ConnectionInfo Purpose="ReadOnly" AltDataSource="">
<udc:WsdlUrl/>
<udc:SelectCommand>
<udc:ListId>2F9fb67e-ab7d-44b7-accc-d9f6c9ca37f9</udc:ListId>
<udc:WebUrl>http://moss-server/MySiteCollection/</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=""/>
</udc:UpdateCommand>
<!--udc:Authentication><udc:SSO AppId='' CredentialType='' /></udc:Authentication-->
</udc:ConnectionInfo>
</udc:DataSource>
I generated this .UDCX file with InfoPath using the Convert button on the Data Sources form. As you can see from the ListId element is conveniently hard coded with the GUID of a list. That makes this .UDCX file absolutely worthless when deployed to a new server. I looked for some documentation .UDCX to see if I could put a path in for the ListId, but I couldn’t find anything that stated I could. I tried the path (i.e.: Lists/MyCustomList) and I got a list not found error when I tried to open the form. So I then decided to just specify the list by its name and sure enough it works. Here is what it looks like.
<?xml version="1.0" encoding="UTF-8"?>
<?MicrosoftWindowsSharePointServices ContentTypeID="0x010100B4CBD48E029A4ad8B62CB0E41868F2BF"?>
<udc:DataSource MajorVersion="2" MinorVersion="0" xmlns:udc="http://schemas.microsoft.com/office/infopath/2006/udc">
<udc:Name>list_2f9fb67e-ab7d-44b7-accc-d9f6c9ca37f9</udc:Name>
<udc:Description>Format: UDC V2; Connection Type: SharePointList; Purpose: ReadOnly; Generated by Microsoft Office InfoPath 2007 on 2009-10-05 at 15:02:14 by MOSS-SERVER\moss_setup.</udc:Description>
<udc:Type MajorVersion="2" MinorVersion="0" Type="SharePointList">
<udc:SubType MajorVersion="0" MinorVersion="0" Type=""/>
</udc:Type>
<udc:ConnectionInfo Purpose="ReadOnly" AltDataSource="">
<udc:WsdlUrl/>
<udc:SelectCommand>
<udc:ListId>MyCustomList</udc:ListId>
<udc:WebUrl>http://moss-server/MySiteCollection/</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=""/>
</udc:UpdateCommand>
<!--udc:Authentication><udc:SSO AppId='' CredentialType='' /></udc:Authentication-->
</udc:ConnectionInfo>
</udc:DataSource>
As you can see I just specified the name of my custom list and it works great. I still have to update the WebUrl when I put this on a new server, but this eliminates the hassle of having to look up and deal with list Ids.