共用方式為


Business Connectivity Services Error “Edit form not found” or “New Form not found”

I recently came across an issue while working with Business Connectivity Services. When developing with BCS its pretty common to implement your “ReadList” and “ReadItem” methods first, create the external list and test the functionality and then go back and implement the “Create”, “Update” and “Delete”

In this case after you re-deploy your BDC project you will receive an error “Edit form not found” when you try to edit a list item, also when you click on “New Item” you will receive an error “New Form Not found”. Issue is the ribbon links show up for New and Update as soon as you re-deploy your BDC project leading you to believe all is good

Fix for this is you need to re-create your External list, as a developer this could be annoying but SharePoint team did not feel like issue was high priority one to spend lot of time and effort to fix.

If you are a developer like me what you can do to make your life little bit easy is create another web scoped feature in your BDC project and hook into feature activation to programmatically create the external list, similarly you can also hook into  feature deactivation event to do some cleanup work and delete the external list

Sample code that programmatically creates and external list in feature activation event handler:

 public override void FeatureActivated(SPFeatureReceiverProperties properties)
 {
       SPListDataSource ed = new SPListDataSource();
       ed.SetProperty(SPListDataSource.BDCProperties.LobSystemInstance, "{LOB Instance Name}");
       ed.SetProperty(SPListDataSource.BDCProperties.EntityNamespace, "{Namespace.EntityName}");
       ed.SetProperty(SPListDataSource.BDCProperties.Entity, "{Entity Name}");
       ed.SetProperty(SPListDataSource.BDCProperties.SpecificFinder, "{SpecificFinder Method Name}");
  
       SPWeb web = properties.Feature.Parent as SPWeb
       if(web != null)
       {
            web.Lists.Add(“{external list name}”, “{description}”, “Lists/{external list name}”, ed);
       }
 }

Technorati Tags: BCS,SharePoint 2010