Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only writes one row of permissions #1

Open
bingaman opened this issue Apr 8, 2022 · 2 comments
Open

Only writes one row of permissions #1

bingaman opened this issue Apr 8, 2022 · 2 comments

Comments

@bingaman
Copy link

bingaman commented Apr 8, 2022

You're overwriting the permissions row on each loop so it just ends up showing one permission per shared drive

newRow = [this_audit_date, this_drive_id, this_drive_name, value.emailAddress, value.type, value.role];

@mjoyosa
Copy link

mjoyosa commented Aug 18, 2022

Here's what I did to make it write all permissions:

  1. Replace:

    var lastRow = rangeData.getLastRow();
    with:
    var lastRow = rangeData.getNumRows();
    var driveCount = lastRow - 1;

  2. Use driveCount instead of the this constant:

    const NUMBER_OF_ROWS_TO_LOOKUP_PERMISSIONS_PER_LOOP = 100;
    in:
    var searchRange = drives_sheet.getRange(2,1, NUMBER_OF_ROWS_TO_LOOKUP_PERMISSIONS_PER_LOOP, lastColumn);
    and in:
    for ( i = 0; i < NUMBER_OF_ROWS_TO_LOOKUP_PERMISSIONS_PER_LOOP; i++) {

This is will prevent the script from using a blank Drive ID for the permissions query if your Shared Drive list is fewer than the value of NUMBER_OF_ROWS_TO_LOOKUP_PERMISSIONS_PER_LOOP.

  1. This should be included in the loop at line 148 to be able to write all the permissions in the array.

rowsToWrite.push(newRow);

@usaussie
Copy link
Owner

Thanks for the heads up on this issue. -- if you want to add this as a pull request, i'll review again and accept/merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants