Can someone assist me with this script issue? I keep receiving the error message "userID is not defined."
I'm attempting to bulk modify licenses following a tutorial on https://www.youtube.com/watch?v=e4KTAytOeyA
function updateLicenses() {
var updateSheet = SpreadsheetApp.getActive() .getSheetByName("Update Licenses")
var data = updateSheet.getRange(2, 1, updateSheet.getLastRow() - 1, 3).getValues()
var fileArray = [
["License Update Status"]
]
// Iterate through each row in the provided Google Sheet and make API calls
data.forEach(function(item) {
var status = "License Assigned Successfully"
try {
var userId = item[0]
var apiCall = AdminLicenseManager.LicenseAssignments.patch({
// Enter new license details here
"productID": "Google-Apps",
"skuID": "1010020027",
"userID": userId
}, "Google-Apps", "1010020028", userId) // Enter existing/assigned license details here
} catch (e) {
status = e.message
}
fileArray.push([status])
})
updateSheet.getRange(1, 2, fileArray.length, fileArray[0].length).setValues(fileArray)
//AdminLicenseManager.LicenseAssignments.patch()
}