SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I've got a list with a BDC External Data field (Sharepoint 2010). This has been added via code and works well (although some sharepoint hacking was needed!)

Anyway on the front end you go to list settings, edit the "External data" column and you can choose to "Add a column to show each of these additional fields:" and then pick the properties you want

Does anyone know how to do this from code?? Everything else in my deployment is from code so I dont want a manual step as it will get forgotten

Hows its done on the front end

share|improve this question
up vote 1 down vote accepted

You can set the "additional fields" using the SetSecondaryFieldsNames method. You can retrieve the list of secondary fields using the GetSecondaryFieldsNames method.

share|improve this answer
So I have a had a play with this and it works if I do it on teh list field. But does not if I do it on the content type. I get a random "object reference is set to null" when I do the update – Amjid Qureshi Aug 10 '11 at 4:58
sorry meant site column not content type – Amjid Qureshi Aug 10 '11 at 5:04
That's right...there's no container object (i.e. list or content type) for the underlying implementation to add the secondary fields/columns too when dealing with a site column, so it throws and "object reference is set to null" error. That's 100% what I would expect to happen. – Rob D'Oria Aug 10 '11 at 5:30
Just to note, you cannot create a Site Column of type "External Data" thru the UI. – Rob D'Oria Aug 10 '11 at 13:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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