Thursday, January 10, 2013

Insert value into a Column which lookup data from an External List

http://social.technet.microsoft.com/forums/en-US/sharepointdevelopmentprevious/thread/490dc593-5a18-47fc-9b66-00567efcc61c/
http://zimmergren.net/technical/sp-2010-programmatically-work-with-external-lists-bcs-using-the-client-object-model

http://msdn.microsoft.com/en-us/library/microsoft.businessdata.metadatamodel.ientity.getfinderview.aspx

http://msdn.microsoft.com/en-us/library/ff798357.aspx

And finally ... when none of the above is working, I found the correct approach

http://wadehuntersblog.blogspot.co.uk/2008/10/progrmatically-set-bdc-column.html
http://dotnetfollower.com/wordpress/2011/12/sharepoint-understanding-businessdata-column-bdc-field/

I have used code similar to:

SPField bdcField = spItem.Fields[sBDCColumnName];
XmlDocument xmlData = new XmlDocument();
xmlData.LoadXml(bdcField.SchemaXml);
String sEntityName = xmlData.FirstChild.Attributes["RelatedFieldWssStaticName"].Value;

spItem[sEntityName] = EntityInstanceIdEncoder.EncodeEntityInstanceId(new object[] { Value });
spItem[sBDCColumnName] = Value;
spItem[ BDCFieldName + ": " + BDCDisplayFieldName ] = "SomeValue";

// ex: spItem["Products: Name"] = "XYZ";


I This works for both External Data Columns and lookup columns created from external lists

No comments:

SSL Error - The connection for this site is not secure

 After cloning a git repo of dot net framework website and trying to run it all I could see was this error Turns out the fix was to simply e...