1

Is it possiblet o get a list of Publishing Pages in a Pages library that have been created, but haven't been checked in after initially creating the page?

SPList.ItemCount does give the correct amount of items, including these pages that have been created but not even checked in once. However, SPList.GetItems query ignores those pages - also SPList.Items collection ignores these pages.

Any ideas?

  • 1
    I'm sure there is a way, they give you a means in the Library Settings to check for files with no checked in version. I don't know what that is using under the hood. – Eric Alexander Feb 12 '15 at 14:52
2

I commonly use:

if (file.CheckOutType != SPFile.SPCheckOutType.None)
{
    file.CheckIn("Programmatically Checked In");
}

Good Luck

1

There is a property called CheckedOutFiles on the Document Library. Additionally you can grab the publishing status via the SPModerationInformation property on the page like so:

SPModerationInformation moderationInformation= page.ListItem.ModerationInformation;
if (moderationInformation.Status == SPModerationStatusType.Pending)

See here for a detailed description of CheckedOutFiles or here for an example of publishing all unpublished pages using SPModerationInformation.

0

You could utilize Moderation Status:

Value:3 The list item is in the draft or checked out state.

Example

The following example demonstrates how to retrieve items in the draft or checked out state:

SPList list = web.Lists.TryGetList("Pages");
var query = new SPQuery();
query.Query = @"<Where><Eq><FieldRef Name='_ModerationStatus'/><Value Type='Number'>3</Value></Eq></Where>";
var items = list.GetItems(query);
  • I'm pretty sure this doesn't work as list.GetItems without _ModerationStatus filter doesn't return the items as they have never been checked in. – Jussi Palo Feb 13 '15 at 16:37

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.