10

I am creating a Content Query Web Part as part of a feature receiver (feature activated), and adding it to a publishing page. The purpose is to filter on the Approval Status field for a Calendar event.

I can successfully filter the data returned by the CQWP by setting the following properties:

            FilterField1 = "_ModerationStatus",
            FilterOperator1 = ContentByQueryWebPart.FilterFieldQueryOperator.Eq,
            FilterValue1 = "Approved",
            FilterType1 = "ModStat",

But if I don't include _ModerationStatus in the AdditionalFilterFields, and you edit the web part, it just shows "no filter" "is equal to" "Approved" in the Additional Filters section of the web part properties.

However, and here is my problem, ANY field I add to the AdditionalFilterFields gets repeated if it's the last field added.

Example:

AdditionalFilterFields = "_ModerationStatus,Approval Status"

will show Approval Status three times in the drop down under "Show items when" in the tool part.

AdditionalFilterFields = "_ModerationStatus,Approval Status;Editor,Modified By"

will show Approval Status once, but the Modified By field three times in the drop down under "Show items when" in the tool part.

AdditionalFilterFields = "_ModerationStatus,Approval Status;Editor,Modified By,InstanceID,Instance ID"

will show Approval Status once, Modified By once, but the Instance ID field three times in the drop down under "Show items when" in the tool part.

Has anyone else encountered this issue creating CQWP's in code?

  • 2
    Have you tried to separate the fields using the semi-colon, ending the last one also in semi-colon? AdditionalFilterFields = "_ModerationStatus;Approval Status;Editor;Modified By;InstanceID;" Configure the CQWP using the browser as you need, then export the webpart and take a look to the XML generated. How it looks the AdditionalFilterFields? – Luis Manez - MS MVP Aug 26 '14 at 7:17
2

Use ; instead of , in your query and also delimit the last column too with ;. It will help you solve the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.