I'm trying to develop a google script to transfer user data to (for example, a [email protected]), after deleting a user account from G Suite Admin SDK. I've tried and am unable to find it anywhere the script to transfer user data after google mail deletion.
function onFormSubmit(e) {
deleteUsers(e);
}
function deleteUsers() {
var ss = SpreadsheetApp.openById('1Z0cNwh2BJLrq1bMQS3eU1tWLrjz2DLUne8CY3rMM7OE');
var sheet = ss.getSheetByName('Delete Users');
var data = sheet.getDataRange().getValues();
var len = data.length;
for(var i=1; i<len; i ){
var user = data[i][0];
var transferToEmail = data["Transfer to Email"][1];
Logger.log(user);
//use try catch in case a user is already removed
try{
AdminDirectory.Users.remove(user);
}
catch(err){}
}
}
CodePudding user response:
Some Google APIs are integrated with Google Apps Script as advanced services, unfortunately the Data Transfer API isn't, that is why on How to execute Data Transfer API? are using UrlFetchApp
to make a HTTP request to call the Data Transfer API instead of something like AdminDirectory
to call the Directory API / Reports API.