I have a Google Apps Script code for our workplace that is meant to take files uploaded to a single folder, and move them to other folders based on their file name. This code is working just fine when I try it with my personal Google Drive, but fails when I try it on our workplace Team Drive. Gives the error "API call to drive.files.update failed with error: File Not found: (line 11)" Line 11 in this case is the Drive.Files.update line.
Troubleshooting so far: Have ensured that resources > advanced Google Services > Drive API v2 is set to on. Works also when I try it on my personal Google My Drive. Does not work on the workplace Team Drive. Cannot tell if this is because of some admin restriction on the Team Drive, or I need to use a different Drive.files.update code when in a Team Drive.
function moveFiles() {
var dfldrs=['ALT CHG', 'ALT ADJ', 'ALT PMT', 'APX CHG', 'APX ADJ', 'APX PMT','AUR CHG', 'AUR ADJ', 'AUR PMT','BEA CHG', 'BEA ADJ', 'BEA PMT'];//Seven letter prefixes
var ofObj={'ALT CHG':'id','ALT ADJ':'id','ALT PMT':'id','APX CHG':'id','APX ADJ':'id','APX PMT':'id-','AUR CHG':'id','AUR ADJ':'id','AUR PMT':'id','BEA CHG':'id','BEA ADJ':'id','BEA PMT':'id'};//distribution folder ids
var upldFldr=DriveApp.getFolderById('id');
var files=upldFldr.getFiles();
while(files.hasNext()) {
var file=files.next();
var key=file.getName().slice(0,7);
var index=dfldrs.indexOf(key);
if(index>-1) {
Drive.Files.update({"parents": [{'id': ofObj[key]}]}, file.getId());
}
}
}