I'm struggling with refreshing items on list with external data. So far I have been able to make the refresh button work, but only when I add items to list in a standard way (via browser). When I add items programatically:

SPListItem targetItem = list.Items.Add();
SPBusinessDataField dataField = targetItem.Fields["n"] as SPBusinessDataField; // external data column
dataField.ParseAndSetValue(targetItem, 555);
targetItem[dataField.RelatedField] = targetItem["n"];

I get the errors in log like:

Unexpected exception synchronizing business data item with ID 555, exception System.InvalidOperationException: Encoded identifier is invalid.     at Microsoft.SharePoint.BusinessData.Infrastructure.EntityInstanceIdEncoder.DecodeEntityInstanceId(String encodedId)

I understand the error, encodedId should not be the value of my external data column, the problem is, I don't know what to do so that encodedId would have a correct value (I believe the problem is something with the code for programatically adding items, which I posted )

  • Do you have any additional columns included from your External Data list/column? Commented Dec 1, 2011 at 14:32
  • yes, I have included all additional columns, i use this method set thier values, works ok
    – matt137
    Commented Dec 1, 2011 at 14:48
  • ok, great, just making sure it's in there. What do you mean by refreshing items, like reloading web page? Also When do you get the error? Commented Dec 1, 2011 at 15:18
  • by refresfhing items I mean using the Refresh External Data button that is present in the title of the external data column. The error appears in .../14/Logs log file, it does not appear on the page, where I just get a 'update succesful, 0 items where refershed' message (a bit misleading..)
    – matt137
    Commented Dec 2, 2011 at 7:19


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.