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.

Comments

# re: Specifying a list by name in a .UDCX file

Tuesday, October 20, 2009 10:22 AM by GuyO

Hmmm, better check this again.. The ListId element is a full-blown GUID including the curly braces, without the curly braces, InfoPath will cough up an invalid GUID error message when you attempt to use the it on an entirely new form.  -- The is some odd goings on when udcx file is used on the form from which it was created -- I suspect that with the connection or the data are being cached someplace.   Same goes with the named list -- try using it on an entirely new form -- InfoPath will complain about the invalid GUID when provided the udcx file with the list name...  I really wish that you were right about this...

Guy

# re: Specifying a list by name in a .UDCX file

Tuesday, October 20, 2009 10:54 AM by CoreyRoth

Yeah I didn't think it would work either, but I have successfully deployed this and its working great for me.

# re: Specifying a list by name in a .UDCX file

Monday, November 2, 2009 4:27 PM by BenG

I'm getting the same results as GuyO when using it on a new form. It worked great when connecting to an SP list, then converting, then editing the GUID to the list name. But it didn't work on a new form.

I'll probably manually edit the manifest.xsf and the schema files for the secondary data source, because this functionality is too important. But it's going to be a pain.

# re: Specifying a list by name in a .UDCX file

Monday, November 2, 2009 7:45 PM by BenG

Found the 5 places where data surgery is required, to add a secondary data connection to a udcx that has the list name instead of the list id. aka Corey style udcx.

Create and add a <list name>.xsd to the project.

There's 3 within manifest.xsf.

Add an xsf:file element to xsf:package/xsf:files.

Add an xsf2:dataConnections element to xsf:extension/xsf2:solutionDefinition.

Add an xsf:dataObject to xsf:dataObjects.

Within sampledata.xml add an xd:DataConnection element.

If you're looking for sample elements, look at an existing udcx connection.

# re: Specifying a list by name in a .UDCX file

Tuesday, December 1, 2009 8:53 AM by Camilo Vergara

I try to implement the elements using your code and works perfectly but the title, this service title appears empty on infopath, any ideas about that?

# re: Specifying a list by name in a .UDCX file

Wednesday, October 6, 2010 10:44 PM by puja

This didnt work for me. It complains about the format of GUID.

Also I observed this worked for you because to have <udc:Name>list_2f9fb67e-ab7d-44b7-accc-d9f6c9ca37f9</udc:Name> and

<udc:ListId>MyCustomList</udc:ListId>

SO in a way you have provided GUID already. In my case my UDCX looks like

<udc:Name>MyListName</udc:Name>

<udc:ListId>{cd0dc49f-6a57-4eab-8d59-4458773bc271}</udc:ListId>

Replacing ListId with Name doenst work for me.

Can some post a reply I need to move my form template from development to production. And I donot know List ID in advance.

Leave a Comment

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