14

I don´t want to ask the same question here again. But to understand the origin of my question this could be helpful (https://stackoverflow.com/questions/26054246/sharepoint-2013-fetch-only-last-approved-version-through-rest-api).

Now I found out that:

  • It is not possible to reflect the approval status in an item to make it visible in a json response from rest api call. This is because you cannot use field approval status in a calculated field and the field itself is not populated through rest response.

  • I tried to set a custom field item_approval_status through a workflow but this is messing up workflows because this workflow is making a change to the item which causes other necessary workflows to start (could end up in infinite loop..)

So what I want to achieve is:

Favorite:

To make 1 rest call and get only the last approved version of an item for ALL users (even those who are allowed to see drafts)!

Workaround:

To reflect the current approval status in each item to (at least) provide a label to each item that is not approved. So approvers and the author can see that this is the draft state.

12

Try using OData__ModerationStatus if you're using the _api endpoints in 2013.

0 = Approved, 1 = Rejected, 2 = Pending, 3 = Draft

So you would use a URL ending with an OData filter command like:

".../items?$filter=OData__ModerationStatus eq 0"

Note: it's actually two underscores between OData and ModerationStatus.

  • Hi, thanks for your answer. I know that but that only fetches the approved or not_approved items and does not implement the approval status in each response item. What I was missing is the approval status field in each item of the response. – Worn Oct 7 '14 at 15:29
  • 1
    Hi, just tried (although I hav another solution now) and you are right! OData_ModerationStatus is reflecting the moderation status in each result item. Nice! Important is that you can use this in $select not only in $filter (what is not possible with field ModerationStatus). – Worn Oct 24 '14 at 7:57
  • this question and answer more usable who googling and find this article for filter rest api approve/reject but SharePoint by default works correct and when execute rests without this filter also worked as this. please tell me why this answer voted up for that custom approve field that questioner wanna request us to help? – saber tabatabaee yazdi Nov 6 '16 at 7:36
  • i added draft and edit this answer. number 3 is status number for Draft but if you enable minor version and enabling minor version fire a mistake that describe in this link sharepoint.stackexchange.com/q/149306/5170 – saber tabatabaee yazdi Dec 13 '16 at 13:59
  • update works with OData__ModerationStatus – Amit Bhagat Sep 26 '18 at 15:59

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.