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:

c# httpclient The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

 If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remo...