1

I'm kind of stuck in a Content by Query Webpart.

(Yes, i'm aware i'm on 2013, and yes, i could use Content by Search WebPart, but this is a standard edition, so no, finally i can't use CSWP)

I would like to show only pages with the Approval Status set to Approved.

I saw that the code for "Approved" is 16. (here lays my source )

But, when i'm on my CQWP settings, the "Approval Status" does not show in the query Filter dropdowns.

I saw this blog article And tried to make it work, but i can't edit my homepage.aspx into Sharepoint Designer 2013.

So, i've created a filter on "created" eq [Today] in the CQWP settings, exported it, and tried to change the FilterField2 to the GUID of Approval Status and FilterDisplayValue2 by "16". And then reimport the CQWP...

But it did not work and made all my page to bug severly.

Do you have any idea on how to filter a Query of a CQWP by the Approval Status, please?

Thanks a lot in advance!

2

I finally found the way to do it myself. I'm posting here my discovery, but be careful, you have no warranties it will work on YOUR environment or if there is some migration, we have no warranty it won't break.

So, to add a filter on the Approval Status in a CQWP, you'll have to:

  1. Export your CQWP (go on your page, click "Edit Page", select your CQWP and click "Export". Register on you computer.
  2. Modify your CQWP and add an AdditionalFilterField : Find the tag <property name="AdditionalFilterFields" type="string"/> and add filter fields like this :

<property name="AdditionalFilterFields" type="string"> InternalNameOfFIeld01,TypeOfField01;InternalNameOfField02,TypeOfField02</property>

  1. In fact, the Approval status is a bit complicated, but by browing google, i found what i was loking for : internal name = _ModerationStatus. Type = ModStat So your AdditionalFilterField should look like this :

<property name="AdditionalFilterFields" type="string">_ModerationStatus,ModStat</property>

  1. Save and import your CQWP file into your WebPart gallery. Give it a name, I suggest you to put it in a custom group
  2. Then, on your page, add a new WebPart, and take the newly uploaded one!
  3. Now, just edit your webpart, and in the Query filters, add a filter on the filed "ModStat" "equal to"(or whatever you want as an operator) "Approved".

Notes : I've read several time that Approval status was a number, and that "Approval" was equal to 16. i've tried it, it does not work.

So, if your webpart has to appear on sites with different languages possibilities, be carefull : this solution may not work!

0

_ModerationStatus is what I was looking for, and I was able to add it to a Managed Property in Search. However, if Content Approval isn't enabled the _ModerationStatus is set to 0, just as it would be with no approval enabled. So can't filter on it without picking up those items without approval on.

0

Try using these enums instead. They work for me.

0 - Approved

1 - Rejected

2 - Pending

3 - Draft

4 - Scheduled

However I personally still have the issue where Approval Status only works for administrators and not team site visitors.

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.