Daryl Rasmussen's Not-so-random Thoughts about SharePoint Here in my world

Archive for the ‘Content Types’ Category

Coding External Content Types

I was trying to follow the example given here:

http://www.sharemuch.com/2010/01/29/using-sharepoint-2010-external-lists-programmatically/

However, it didn’t work for me. This link looked slightly more promising:

http://www.sharemuch.com/2010/05/03/creating-sharepoint-2010-bdc-list-instances-in-programmatically/

But I still was having trouble figuring out in SP Here whether the “External System” shown in Central Admin on the Manage BDC Services page was the LOB Name, or the LOB instance name, or the Model Name, and therefore, confused about what to put in the properties in our specific instance in order to get the Holiday list working from a client’s Dynamics (DAX) based database on the above examples.

To make matters worse, both of the above links, and the post here

http://pholpar.wordpress.com/2010/08/23/creating-external-lists-from-code/

say that the format for the EntityNamespace property is supposed to have “dot” notation.

Trial and error and a bit of dogged persistence, and I finally figured it out on my own. The final post above needs 1 correction to make it work (I replied to the author’s post on-line in 2012 when I encountered the issue, but as of Feb 2015, my comments are still not visible there). It took me a few hours to figure this out, but the fact that the documentation here does not mention any prefix or dot-notation should have been my first clue. Basically, you need to change

listDataSource.SetProperty(SPListDataSource.BDCProperties.EntityNamespace, “YourBdc.EntityNamespace”);

To

listDataSource.SetProperty(SPListDataSource.BDCProperties.EntityNamespace, “EntityNamespace”);

In other words do not prefix the EntityNamespace with “YourBdc.”, or you will get an error that says: Entity (external Content Type) cannot be found with Namespace= “YourBdc.EntityNamespace” , Name = “YourBdcEntity” The error is thrown on the call to list.Add.

Tag Cloud