This project is read-only.

Lists with Lookup columns fail


If a list has some lookup columns like "App Created By" for example, then the code fails when we try to execute SPList.Count(SPQuery). On investigating the code, I found that, this is happening due the failure in conversion of string to GUID. There is a line which tries to read the Field Schema and tries to convert the value of "List" attribute to a GUID, assuming that it will be a GUID. This will work for normal lists which will have a GUID value for the List attribute, but in case of Lookups, this will store the list name and not the list GUID. Hence it will fail. Please update the code and the dll. This issue is in the constructor of the FieldInfo.cs.

It looks like this happens in 2013. For example, I have a custom list which has an inbuilt column called "App Created By". This is a lookup field, whose lookup list is "AppPrincipals".
var listStr = element.AttributeValueString("List", string.Empty); // this will give List Name for lookup field
var lookupListId = new Guid(listStr); // this will break if listStr is List Name instead of List GUID