SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 )

share|improve this question
Do you have any additional columns included from your External Data list/column? – David Lozzi Dec 1 '11 at 14:32
yes, I have included all additional columns, i use this method set thier values, works ok – matt137 Dec 1 '11 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? – David Lozzi Dec 1 '11 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 Dec 2 '11 at 7:19

Your Answer


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

Browse other questions tagged or ask your own question.