2

It maybe a SharePoint dummy level question for but I cannot find a way to do it.

In the Pages library we have enabled publishing feature. Only major version 1.0, 2.0, 3.0... are published and minor version are draft. I want to create a view to show all unpublished pages (and another view for all published pages). I can add a column shows version number only.

Can I accomplish it without programming?

1

3 Answers 3

5

Without code

On library click Create new view based on for ex. All items. Check columns you want to view and sort it how you like.

Under Filter

click Show items only when the following is true

Approval Status --- is greater than --- 0 << this is for all unpublished(Rejected, Pending, Draft)

Click OK

For Published view create one more view with

Approval Status --- is equal to --- 0 << this is for published(Approved)

And that's it

Reference

Display Name --- Approval Status

Internal Name --- _ModerationStatus

GUID --- {fdc3b2ed-5bf2-4835-a4bc-b885f3396a61}

Type --- ModStat


FYI

Status --- Internal Value

Approved --- 0

Rejected --- 1

Pending --- 2

Draft --- 3

Scheduled --- 4


EDIT

With code

unpublished-view

In the Code view just paste the following into your View’s XML inside the Query element:

<Where>
<Or>
    <Eq>
        <FieldRef Name="_ModerationStatus"/>
        <Value Type="ModStat">Draft</Value>
    </Eq>
    <IsNotNull>
        <FieldRef Name="CheckoutUser"/>
    </IsNotNull>
</Or>
</Where>

EDIT FINAL

If content Approval is disabled you can't see Approval status in edit view under filters so you must add it in code for that 2 new views (published.aspx and draft.aspx). Open SPDesigner and go to Pages/forms and edit that view. Find <Query> and paste that code after <Query>

For Draft view:

<Where>
<Or>
    <Eq>
        <FieldRef Name="_ModerationStatus"/>
        <Value Type="ModStat">Draft</Value>
    </Eq>
    <IsNotNull>
        <FieldRef Name="CheckoutUser"/>
    </IsNotNull>
</Or>
</Where>

For Publish view:

<Where>
<Or>
    <Eq>
        <FieldRef Name="_ModerationStatus"/>
        <Value Type="ModStat">Approved</Value>
    </Eq>
    <IsNotNull>
        <FieldRef Name="CheckoutUser"/>
    </IsNotNull>
</Or>
</Where>

*You can set 3 for Draft and 0 for Approved for _ModerationStatus value.

Save file and that's it. :)

5
  • I have not enabled content approval for Pages library. Will it still work?
    – Mark L
    Sep 25, 2014 at 8:53
  • Try without. Library > Library Settings; Versioning Settings; Content Approval : Yes; Document Version History : Create major and minor (draft) versions;
    – Marko Tica
    Sep 25, 2014 at 11:19
  • So I must enable content approval?
    – Mark L
    Sep 28, 2014 at 1:31
  • You don't need to enable Content Approval. And then value for status Approved is 0 and for Draft status is 3. If you enable Content Approval then you have more statuses. Rejceted is 1, Pending is 2 and Scheduled is 4.
    – Marko Tica
    Sep 29, 2014 at 7:48
  • If Content Approval is enabled you can edit view from UI and if Content Approval is disabled you must edit view through code (see EDIT FINAL in my answer)
    – Marko Tica
    Sep 29, 2014 at 8:35
0

The other easiest method is to create a calculated column with formula =IF((Version-INT(Version))<>0,"Draft","Published") and use the column in a view.

For detailed explanation you can visit this article.

0

Unfortunately, the current answers are not applicable for SharePoint Online and approval turned off (... and no programming with e.g. PnP.PowerShell against my SPO pages library).

When turning on approval like Marko Tica recommended (with nice insights in approval status values), I could create the filtered view with approval status, but after removing approval from the library settings, the column was gone and the view did not work anymore.

The solution of Kannan with a calculated field I liked, but it seems, that in SPO pages library, you cannot reference the Version field in the UI. By the way, I had to look up the referenced blog article, the updated link is now here.

I ended up just creating a view that is sorting descending by Modified date to have most unpublished pages on top for easier selecting when bulk publishing ... :/

1
  • So, you can create different views by the version number, as it is always ending with ".0" for published items. So, for the "Published" view, you would need a filter "version ends with '.0' ", which is not available, but you could use the Filter criteria "version contains '.0' " For the "Unpublished" view, you would need a "version does not end with '.0'", which does also not exist, but you can add additional columns to the filter criteria, so that you have 9 filters combined by OR which result in "version contains '.1' OR '.2' OR '.3' OR '.4' OR '.5' OR '.6' OR '.7' OR '.8' OR '.9'"
    – AIsmaili
    Sep 6 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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