Pnpjs: Batch add/remove users to sitegroup

Created on 19 Mar 2019  路  2Comments  路  Source: pnp/pnpjs

Category

  • [ ] Enhancement
  • [ ] Bug
  • [x] Question
  • [ ] Documentation gap/issue

Version

Please specify what version of the library you are using: 1.2.9

Please specify what version(s) of SharePoint you are targeting: Online

Expected / Desired Behavior / Question

I want to add / remove multiples users to a Site Group through batch command.

Observed Behavior

When I try to add / remove multiples users to a Site Group through batch command, nothing happens. Here's the code for add case:

const batch = this._currentWeb.createBatch();

this._currentWeb.siteGroups.getById(siteGroupId).users.inBatch(batch).add(user.id)
      .then((value: SiteUser) => {
        console.log(value);
      })
      .catch((error) => {
        console.log(error);
      });
    }

    await batch.execute()
    .then(() => {
      isOk = true
    })
    .catch((error) => {
      console.log(error)
    });

If I remove the "inBatch" part, it works both for adding and removing. Am I doing something wrong ?

Thank you for your help.

Steps to Reproduce

N/A

Submission Guidelines

code fixed bug

Most helpful comment

Ok, got a fix for this in #581

All 2 comments

Just had a look, this is a bug in how the batch is getting processed. Working on a fix. Thanks!

Edit: this is the same issue but in the items case: https://github.com/pnp/pnpjs/issues/468

Ok, got a fix for this in #581

Was this page helpful?
0 / 5 - 0 ratings