Question

Aleksey Kachanov on Wed, 19 Oct 2011 08:35:59


There is a list with External Data column

Requires to set the column reference to the External List item.

Currently I can to set only value to the primary and secondary fields using the code from the following link:

http://jsiegmund.wordpress.com/2010/12/03/sp2010-setting-bcs-column-and-related-fields/

But if try to refresh data in the external data column it's doesn't do it.

What is the other approach to set the External Data column that refresh data works correct

 

Thanks in advance. 


Sponsored



Replies

Dmitry Kaloshin on Wed, 19 Oct 2011 09:59:15


Hi,

Please take a look at these threads:

Aleksey Kachanov on Wed, 19 Oct 2011 11:33:28


Right answer is here 

http://blog.domcosgrove.com/setting-the-value-of-a-bdc-field-programmatically/

 

But also it doesn't resolve issue to update related fields automatically

Dmitry Kaloshin on Wed, 19 Oct 2011 11:35:26


Please describe the problem you are experiencing.

Aleksey Kachanov on Wed, 19 Oct 2011 12:48:59


If you just set the value to the BCS column using the following code:

 

Guid key = new Guid((string)item["EntityID"]);
XmlDocument xmlData = new XmlDocument();
                   xmlData.LoadXml(field.SchemaXml);
                   String sEntityName = xmlData.FirstChild.Attributes["RelatedFieldWssStaticName"].Value;

                   item[sEntityName] = EntityInstanceIdEncoder.EncodeEntityInstanceId(new object[] { key });

item[sEntityName] = EntityInstanceIdEncoder.EncodeEntityInstanceId(new object[] { key });
                   item[field.Title] = key.ToString();


Secondary related fields are not updated automatically and you have to update these fields manually using approach from the following link.

http://jsiegmund.wordpress.com/2010/12/03/sp2010-setting-bcs-column-and-related-fields/

 

But anyway if click refresh button SharePoint itself can update the data.

 

AkshayS on Fri, 23 Dec 2011 02:05:12


Is item in your example the listitem from the listitemcollection of the list having an external data column that you are updating.  In which case item["EntityID"] there is a column called EntityID in this list? Also the sEntityName is also a column in this list? Or are you referring to a list that is auto created from the external data content type?  Also the msdn documentation says EncodeEntityInstanceId API is obsolete in which case what should you be using to update a cloumn's value in a list that is of type external data?

Robert Kaucher on Thu, 04 Oct 2012 17:06:38


Right answer is here 

http://blog.domcosgrove.com/setting-the-value-of-a-bdc-field-programmatically/

 

But also it doesn't resolve issue to update related fields automatically

Please at least partially describe the methods used in the blog post. The link you provided is now dead and therefore your answer is useless. Providing at the least a high level overview of the blog post increases the utility of your answers as well as the utility of the forum in general.