0

I have a news portal, and I only want to show the approved news. It is possible, with pnp js in SharePoint 2019? I try filter with ModerationStatus, OData__ModerationStatus and _ModerationStatus name, but I cannot solve the problem. Any idea? Thanks!

let folder = await sp.web.getFolderByServerRelativeUrl("/folder");
var today = new Date();
today.setHours(0, 0, 0, 0);

await sp.web.lists.getByTitle("ListTitle").currentUserHasPermissions(PermissionKind.ManageLists).then(perms => {
  this.IsCurrentUserReader = !perms;
  this._updateCallback;
});

await folder.files.expand("ListItemAllFields").orderBy("TimeCreated", false).filter('ListItemAllFields/ModerationStatus eq 0').get().then(items => {
  this.ItemCount = items.length;
  if (items.length == 0) {
    this.ErrorMessage = "There is not news";
    this._updateCallback();
  }
  • Are you getting any error or are you getting all files ignoring status filter? – Ganesh Sanap May 5 at 9:19
  • I don't get any error, but no news is displayed – odass3 May 5 at 10:11
  • It is possible, that I give wrong parameter or fieldname? – odass3 May 5 at 10:19
  • Field name should be its internal name. i.e OData__ModerationStatus. (with two _). – Ganesh Sanap May 5 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.