Sunday, 27 March 2011

"File has been modified by..." errors

I used to get this error message frequently when working with event receivers (typically for document adding), now there are various possible situations that might cause this error(system.update(false)) etc but i found that in my situation, checking the version level of the ListItem helped remove these errors:

e.g.


if (oItem.Versions[0].Level.ToString().Equals("Published") )

Getting a BCS Column related field name

Whilst some people might go through the process of using an XML parsing to get the RelatedField static name for a BCS Column(typically to set it e.g.) :


SPField tagField = oItem.Fields["Account"];                             

XmlDocument xml = new XmlDocument();

xml.LoadXml(tagField.SchemaXml);

String sEntityName2 = xml.FirstChild.Attributes["RelatedFieldWssStaticName"].Value;

I think a more quicker and efficient way is to do the following :


tagField.RelatedField.ToString();