0

I'm trying to use the Client Side Object Model of SharePoint 2013 to read a managed meta data field but I get null results

When I look in the Site Columns, there are 5 fields in the "GroupName" column group that should be returned:

  • 1 single line of text field
  • 4 managed metadata fields

I'm using this C# to get the columns in the group:

private void StackDemo(){
    string contextUrl = "http://mysitecollection/sites/mysite";
    string columnGroup = "GroupName";
    var ctx = new ClientContext(contextUrl)
    {
        Credentials = CredentialCache.DefaultCredentials
    };
    var query = ctx.LoadQuery(from x in ctx.Web.Fields where x.Group== columnGroup select x);

    ctx.ExecuteQuery();
    return query.FirstOrDefault();
}

When I view the query results I can view the plain text field, but all the other fields are null (see screenshot)

screen capture

The weird thing is there is a result for each metadata field, but the value is null.

I want to

  1. Know why I'm getting nulls, even though the query is returning 5 items as expected

  2. Get the field's internal names of the managed metadata columns

2 Answers 2

0

Make sure you have enough permissions (at least Read Access to Term Store) to access a Managed Metadata Service. Please refer an article Grant permission to access the managed metadata service for a details.

Alternatively you could utilize SharePoint REST service to query field internal names of the managed metadata columns:

/_api/web/fields?$select=InternalName&$filter=TypeDisplayName eq 'Managed Metadata'
0

It turns out that it was a case of incorrect SharePoint references.

I started out developing for SharePoint 2010 but during the development period the server was updated to SharePoint 2013. So the references in my project were related to the 14 hive DLLs. Updating these to use the 15 hive DLLs resulted in the fields being retrieved correctly

Your Answer

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

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