3

I have a TermSet called "Products" inside Term Store Management/Managed Metadata. I am designing a front end form which allow user's to submit data to this list. To load the Product dropdown I need to pull all the available Items/Value from this Managed Metadata List.

I am not able to figure out how to build the CAML query for this. How to get the names of particular "Products" from Term store or get it using Client Object Modal (with SharePoint 2010)?

Any help would be highly appreciated.

1 Answer 1

2

This will probably help:

http://blogs.msdn.com/b/sharepointdev/archive/2011/11/18/how-to-work-with-managed-metadata-columns-by-using-the-sharepoint-client-object-model-kaushalendra-kumar.aspx

Here's what i've done to get the items:

    ClientContext hrMainCtx = new ClientContext(siteURLhere);
    hrMainCtx.Credentials = new NetworkCredential("username", "password", "domain");

    List taxonomyHiddenList = hrMainCtx.Web.Lists.GetByTitle("TaxonomyHiddenList");
    ListItemCollection taxonomyListCol = taxonomyHiddenList.GetItems(CamlQuery.CreateAllItemsQuery());
    hrMainCtx.Load(taxonomyListCol);
    hrMainCtx.Load(taxonomyHiddenList);
    hrMainCtx.ExecuteQuery();

then for querying I've done something like this to get the specific items:

    foreach (ListItem oListItem in taxonomyListCol)
    {
        if (oListItem.FieldValues["Path"].ToString() == countryName) 
        {
            countryID = oListItem.FieldValues["ID"].ToString();
            countryTermID = oListItem.FieldValues["IdForTerm"].ToString();
        }
        else if (oListItem.FieldValues["Path"].ToString() == physLocation) 
        {
            phyLocID = oListItem.FieldValues["ID"].ToString();
            phyLocTermID = oListItem.FieldValues["IdForTerm"].ToString();
        }
    }

hopefully this will give you some idea on how to get the items from the hidden list...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.