0

So I've made a time a go a Google Picker for my team which worked great, with DocsView.setOwnedByMe set to true. I needed a picker to show only PDFs created for each user and this was fine, whenever I wasn't using Shared Drives (ex Team Drives). We got a shared folder and every file uploaded or created in it was owned by the user.

Now, with Shared Drives, the ownership belongs to the organization. So, this method "setOwnedByMe" doesn't work anymore to show only user's created files.

I do not find any method like "setCreatedByMe", so I ask: is there anyother workaround to achieve this?

Thanks a lot!

  • You can create a view with `setEnableDrives()` to show the files on the shared Drive to which the user has access, however as you stated correctly, on Shared Drives, there is no ownership. `setCreatedByMe` unfortunately does not exist. – ziganotschka May 23 '22 at 07:58

1 Answers1

0

Get information from shared drive

function getFileInfoFromSharedDrivesxx() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName('Sheet1');
  var driveId = "";
  var token = '';
  var vA = [[driveId, "", "", ""], ["Id", "MimeType", "Kind", "Title"]];
  do {
    let resp = Drive.Files.list({ supportsAllDrives: true, corpora: "drive", includeItemsFromAllDrives: true, driveId: driveId, pageToken: token});
    token = resp.nextPageToken;
    for (let i = 0; i < resp.items.length; i++) {
      let item = resp.items[i];
      vA.push([item.id, item.mimeType, item.kind, item.title]);
    }
  } while (token)
  sh.getRange(sh.getLastRow() + 1, 1, vA.length, vA[0].length).setValues(vA);
  SpreadsheetApp.flush();
}
Cooper
  • 59,616
  • 6
  • 23
  • 54