DocumentQuery API to find unpublished

Ralph McLemore asked on September 11, 2014 05:02

in the example

var news = DocumentHelper.GetDocuments("CMS.News") 
.OnSite("CorporateSite") 
.Path("/News", PathTypeEnum.Children) 
.Published();

it will find only published pages (and you can put false to find all). is there an opposite? to find only archived or unpublished documents?

Correct Answer

Ralph McLemore answered on September 11, 2014 07:16

I figured it out. .WhereEquals("Published", 0)

0 votesVote for this answer Unmark Correct answer

Recent Answers


Martin Danko answered on September 12, 2014 11:16

Hello Ralph,

you should be also able simply to use the false parameter with Published() method:

var news = DocumentHelper.GetDocuments("CMS.News") 
.OnSite("CorporateSite") 
.Path("/News", PathTypeEnum.Children) 
.Published(false);

Best regards, Martin

0 votesVote for this answer Mark as a Correct answer

Yev Fes answered on September 17, 2015 17:18

Martin, is this true?

Does .Published(false) retrieve JUST the unpublished documents, or published AND unpublished?

From my tests its both published and unpublished.

0 votesVote for this answer Mark as a Correct answer

Martin Danko answered on October 7, 2015 15:00

Hello Yev,

that's correct. This DocumentQuery Parameters is equivalent to "SelectOnlyPublished" parameter of API method -> SelectNodes. I agree, that it could be confusing at the very first sight when you thing that it's setting the value for retrieving published/unpublished documents but in fact it's just setting the value of API method. So it's correct behavior.

Best regards, Martin

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.