In a previous blog post, “Content Query Web Part (CQWP) and events / calendars lists using inconsistent internal column names“, I documented an inconsistency in how certain list columns in the SharePoint 2010 Calendar Lists are setup and how the scope of your CQWP could cause that data to not be returned. I provided a workaround to ensure no matter the scope of your CQWP, the accurate data is returned to your web part.
I have discovered a SharePoint oddity with the solution that can cause an error when you attempt to edit the web part and modify the web part properties after the initial setup.
|Error upon attempting to edit the web part properties|
There is a likelihood that some users will never experience the issue. I was able to successfully implement the solution and not find the error for quite some time because I had no need to edit the web part after the initial setup.
No matter the case though, its unreasonable to expect users to never need or want to change the properties of the web part. This would mean they can never change the sorting, filtering or scope, etc.
I was able to narrow down the cause to be the referencing of both the “StartTime” and “EventDate” columns in my XSL. We know from my previous blog post that only one of those columns is populated, dependent on the scope of the CQWP.
If I removed the reference(s) to those two columns in the custom variable I created, the error would not occur when I attempted to edit the web part. I would then put the references to those two columns back into my variable, refresh the page, attempt to edit the web part and the error would reappear.
There is a property in the CQWP .webpart file called “DataMappings”. We must include the reference to the two column names here as well as in the “CommonViewFields” property as instructed in the original blog.
As I have highlighted in the screenshot below, you can simply add to the end of your “DataMappings” property the reference to “StartDate” and “EventDate”. You do not need to include anything to the right of the colon. Be sure to include the trailing “|” symbol at the end of the property values.
Code to Add:
|Code to add to the “DataMappings property|
After I added the new references into the “DataMappings” property, re-imported my web part back onto the page and/or into the web part gallery, the error no longer occurred. I was able to edit the web part, change the web part scope or any other settings successfully without error.