Wednesday 8 June 2011

SharePoint 2010 Business Connectivity Services (BCS) - Exception when adding new Entities - "Null was returned to FindSpecific (Read Item operation)" - Fix

Scenario: You've set up SharePoint 2010 External Content Types and you receive the following exception when adding a new item to your BCS list:

Form submission failed. (User: DOMAIN\UserName, Form Name: Template, IP: , Request: http://servername/sites/Duet/Lists/Leave Request/Item/newifs.aspx?RootFolder=/sites/Duet/Lists/Leave Request&IsDlg=1#, Form ID: urn:schemas-microsoft-com:office:infopath:entity:-AutoGen-2011-06-08T05:13:33:61Z, Type: DataAdapterException, Exception Message: The server responded with the following error: Null was returned to FindSpecific (Read Item operation).. Null was returned to FindSpecific (Read Item operation).)

Then your Specific Finder (e.g. "GetLeaveRequestById") most likely is not handling calls when an object is newly created (e.g. the Primary Key of the BCS Entity is either blank or 0). Basically, when a new object is created, it will be re-queried by the BCS engine - causing the exception.

To fix, you just have to change your BCS Read Item (e.g. GetLeaveRequestById) to handle a call for newly created objects when the Identifier is Blank or zero - and return a placeholder object with initialized fields.

This will appease BCS and allow it to continue to re-render your external entity list (from SAP services or otherwise)

DDK

2 comments:

Unknown said...

I ran into exactly the same situation. But how to change your BCS Read Item to handle a call for newly created objects when the Identifier is Blank or zero? I am using SP Designer. Thanks a lot!

AdvaComp said...

How does one change your BCS Read Item (e.g. GetLeaveRequestById) to handle a call for newly created objects when the Identifier is Blank or zero?