Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How can I create a Business Data catalog field with the object model? So I want to create a field that utilities business data catalog and not add an item to an already existing list.

share|improve this question
add comment

1 Answer

You will have to be a bit more precise. BDC fields are used in many places and can be defined in many ways: application definitions, user profiles, lists, lobsystems in web parts etc.

below is an example on how to instantiate a BDC field in an SPList, as this is something that usually causes a bit of trouble:

SPListItem item = someList.Items.Add();

// assign fields
..
item["MyProductID"] = EntityInstanceIdEncoder.EncodeEntityInstanceId(new object[]{"1234"}); // this could also be an integer 
..
item.Update();// alternatively use SystemUpdate
share|improve this answer
    
What I meant was that I want to create a list with the object model and then add a field to the list which is a Business Data Catalog field. So I want to add a field and not and item to the list. –  Anonymous Mar 25 '10 at 12:25
    
Havent tested this myself, but found another question with answer on Microsoft forum: social.msdn.microsoft.com/Forums/en-US/sharepointbdc/thread/… You add field using AddFieldAsXml() and the xml definition for the field, and then connect it as a BusinessDataField using system instance, entity and field. –  Anders Rask Mar 25 '10 at 13:50
add comment

Your Answer

 
discard

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