0

I have enabled content approval for a custom list. And I have a html page where the requirement is to show all the approved items in the list using SPServices. With content approval enabled, users with Read/Edit permission(except the author of list item) are able to see only the approved content. But the users with other Higher permission level are able to see the non-approved content as well. Is there any solution available to show only approved content to all users?

2 Answers 2

1

There are a couple of options if you want to manage it within the list.

  1. Edit view and Go to -> 'Filter' -> Select 'Approval Status' column and enter 'Approved'(language sensitive).
  2. If you want to manipulate via any code using this CAML filter to get specific items.

    <Eq> <FieldRef Name='_ModerationStatus' /> <Value Type='ModStat'>'Approved'</Value> </Eq>

    Note: ModerationStatus value is language sensitive remember to translate and use correct word.


Update

C#:

foreach(SPListItem item in items)
{
  foreach(var itmversion in item.Versions)
  {
    if(itmversion.Level == "Published")
    {...}
  }
}

Powershell:

foreach($item in $ListItems)
{
  foreach($version in $item.Versions | ? { ($_.Level -eq "Published") })
  {...}
}
2
  • both the option will filter data based on the current approval status. My requirement is to fetch the last approved version of a list item even if it is currently under pending approval status.
    – Obiliraj
    Jan 2, 2018 at 6:50
  • Update my answer to get item via code.. Jan 2, 2018 at 10:08
0

You can do as suggested, create new view filter with 'Approval Status' is equal to 'Approved': enter image description here

But Why are you want to achieve that?

By default, if you choose "Only users who can approve items (and the author of the item)", with content approval enabled:

1.users with Read/Edit permission(except the author of list item) are able to see the last approved version of a List Item.

2.users (the author of list item) or with other Higher permission level are able to see the non-approved content.

If you configure that only show last Major versions for all users in SharePoint, that is to say no one can approve the document?

Your Answer

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

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