Managed Metadata Columns & Infopath


  • Hey All, 

    Please guide me with a problem I have. I created an Infopath form and published it on a Form Library. It is coming properly.  Now, the next thing I wanna do is I want to add a taxonomy/managed metadata column into it. So, please tell me the way to do it programatically using code-behind.


    Please, help me.


    Friday, April 29, 2011 10:43 AM

All replies

  • In code behind you have to remember that a web browser can only understand HTML and JavaScript.  With this said this post below will show you how to place JavaScript like functions behind buttons on a InfoPath Form.

    If you are looking for more power then this and access the SharePoint object model.  You might want to look at this link to the client side object model which you can also use as you would from JavaScript.

    Good Luck,


    Gary Newman MCSE, MCT, CCNA MCDBA, MCAD, MCSA MCTS SharePoint 2007 Dev & Admin MCPD SharePoint 2010 Development
    Friday, April 29, 2011 1:42 PM
  • Gary,

    Thanks for your help but the links you've given  contains very basic information that I already know.

    Actually I wanna use Managed Metadata into combo box present in my Infopath form.

    Friday, April 29, 2011 2:20 PM
  • Hi Rajdeep,

    You could use the Taxonomy web services to get the managed metadata, and then present it in the combobox in InfoPath.

    1. Open InfoPath
    2. Click "Data" > "From Web Service" > "From SOAP web service"
    3. Type the URL: http://<server>/_vti_bin/TaxonomyClientService.asmx
    4. Click "Next"
    5. Select GetTermSets
    6. Assign the parameters' value
    7. Click Next
    8. Click Next
    9. Click Finish(You can check "Automatically retrieve data when form is opened")

    Now, you will get a datasource with field "GetTermSetResult".
    The next step we need to do is using custom code in InfoPath to convert the GetTermSetResult to datafields in InfoPath.

    For more information, please see:
    Unable to GetTermSets from TaxonomyClientService(Resolved):
    Populating a repeating table in InfoPath programmatically:

    If you have any more questions, please feel free to ask.

    Jinchun Chen

    Jin Chen - MSFT
    Wednesday, May 04, 2011 9:55 AM
  • Hi Jinchun,

    How do I get the values to be used for the parameters for 'GetTermSets'?

    Thanks for your help!


    Monday, February 06, 2012 11:19 PM
  • Have a look at this blog post:

    Kind regards, Frank-Ove

    Thursday, March 01, 2012 11:38 AM
  • I'm trying to read the data coming back from the Datasource, but all attempts just fail.

    When I get to the foreach, only 1 item is there. Anyone see what I'm doing wrong? I'm not sure if the XPathNodeIterator is correctly set...

            private void GetTerms()
                //select the secondary data source
                XPathNavigator root = this.DataSources["GetTermSets"].CreateNavigator();
                XPathNodeIterator xDomNodes = root.Select("/dfs:myFields/dfs:dataFields/tns:GetTermSetsResponse/tns:GetTermSetsResult", this.NamespaceManager);
                foreach (XPathNavigator xDom in xDomNodes)
                    XmlDocument doc = new XmlDocument();
                    //set first field(column)
                    XmlNode group = doc.CreateElement("RepeatingTable", NamespaceManager.LookupNamespace("my"));
                    XmlNode field = doc.CreateElement("RPField1", NamespaceManager.LookupNamespace("my"));
                    XmlNode node = group.AppendChild(field);
                    XPathNavigator nav = xDom.SelectSingleNode("@a32", NamespaceManager);
                    node.InnerText = nav != null ? nav.Value : string.Empty;
                    //set second field(column)
                    field = doc.CreateElement("RPField2", NamespaceManager.LookupNamespace("my"));
                    node = group.AppendChild(field);
                    //node.InnerText = xDom.SelectSingleNode("@Field2", NamespaceManager).Value;
                    //populate repeating table with xml of database values
                    //MainDataSource.CreateNavigator().SelectSingleNode("/my:MineFelt/my:group1", this.NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator());
                //remove empty row
                XPathNavigator firstNode = MainDataSource.CreateNavigator().SelectSingleNode("/my:MineFelt/my:group1/my:group2[1]", NamespaceManager);

    Here's the XML that's returned from the datasource:

        <TS a9="4feca2c8-eeed-478e-8016-cea59846fa8f" a17="true" a11="" a16="false" a12="Målgruppe" a68="" />
        <T a9="79c0cb4f-0c23-48e4-b6e2-c4b0700c1107" a21="false" a61="0">
            <TL a32="Hele Sira-Kvina" a31="true" />
          <DS />
            <TM a24="4feca2c8-eeed-478e-8016-cea59846fa8f" a12="Målgruppe" a40="" a17="true" a67="" a45="79c0cb4f-0c23-48e4-b6e2-c4b0700c1107" a69="true" />
        <T a9="1a99dab4-d842-489a-bef3-423a657eed11" a21="false" a61="0">
            <TL a32="Kraftverksgruppe felles" a31="true" />
          <DS />
            <TM a24="4feca2c8-eeed-478e-8016-cea59846fa8f" a12="Målgruppe" a40="" a17="true" a67="" a45="1a99dab4-d842-489a-bef3-423a657eed11" a69="true" />
        <T a9="e22733a8-6a5c-48eb-adca-a41f0af2f3e5" a21="false" a61="0">
            <TL a32="Kraftverksgruppe nord" a31="true" />
          <DS />
            <TM a24="4feca2c8-eeed-478e-8016-cea59846fa8f" a12="Målgruppe" a40="" a17="true" a67="" a45="e22733a8-6a5c-48eb-adca-a41f0af2f3e5" a69="true" />
        <T a9="372c4647-6867-4b9d-83b3-3d3519245cee" a21="false" a61="0">
            <TL a32="Kraftverksgruppe sør" a31="true" />
          <DS />
            <TM a24="4feca2c8-eeed-478e-8016-cea59846fa8f" a12="Målgruppe" a40="" a17="true" a67="" a45="372c4647-6867-4b9d-83b3-3d3519245cee" a69="true" />

    Hope someone can help me.

    Kind regards, Frank-Ove

    • Edited by Frank-Ove Wednesday, March 07, 2012 10:50 PM Shortened XML example
    Wednesday, March 07, 2012 10:46 PM
  • Yes you only get 1 response but the contents is XML itself. Therefore, you need to load that in as an XML document and then loop through the terms.

                    string resultXML = rows.Current.SelectSingleNode("tns:GetTermSetsResult", NamespaceManager).Value.ToString();
                    XmlDocument termSetXML = new XmlDocument();
                    XmlNodeList terms = termSetXML.GetElementsByTagName("T");
                    foreach (XmlNode term in terms)

                            **** do what you need to do here


    A full solution will be described in SharePoint 2010 Managed Metadata Unleashed:

    • Edited by SteveTheManMann Monday, August 20, 2012 1:23 PM corrected title
    Monday, August 20, 2012 1:23 PM
  • Hello,

    I typed in the URL (step 3) and it said 'The file is not a valid XML file.' and that infopath is not able to find the web service or the access is not possible. Why is it not working? Thank you!

    Tuesday, August 02, 2016 1:27 PM