I have few accounts where I need to transfer the ownership to another account. I have the list listed in google sheets with all the email addresses. I am using the code below to hopefully execute it but I am not sure what to use to execute the code.
function dataTransfer() {
var ss = SpreadsheetApp.openById("SHEETID")
var sheet = ss.getSheetByName("SHEETNAME");
var start = 2;
var end = sheet.getLastRow();
var range = sheet.getRange(start,1,end,sheet.getLastColumn());
var values = range.getValues();
for (var i = 0; i < values.length-1; i++) {
/* transfer the data ownership to */
var A = "aUser@company1.com";
var B = "bUser@company1.com";
var C = "cUser@company1.com";
var email = values[i][0];
var company = values[i][1];
var status = values[i][3];
if (status === "Complete") {continue;}
if (company == "A") {
/* transfer of the ownership of user data between users. */
var transferObject = {
"kind": "admin#datatransfer#DataTransfer",
"oldOwnerUserId": email,
"newOwnerUserId": A,
"applicationDataTransfers": [
{
"applicationId": XXXXXX,
"applicationTransferParams": [{
"key": "PRIVACY_LEVEL",
"value": [
"PRIVATE",
"SHARED"
]
}],
"applicationId": XXXXX,
"applicationTransferParams": [{
"key": "RELEASE_RESOURCES",
"value": true
}],
}],
}
**admin.datatransfer....** /* what do I use here to execute the above code */
sheet.getRange(start+i,4,1,1).setValue("Complete");
}
}
}
}