为什么我没有定义“ userId”。
您能帮我提供以下脚本吗?我得到的“未定义”。
我正在尝试根据 https://wwww.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"]
]
// Loop through all user provided google sheet rows and call Directy API with it
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 exiting/assigned license details here
} catch (e) {
var status = e.message
}
fileArray.push([status])
})
updateSheet.getRange(1, 2, fileArray.length, fileArray[0].length).setValues(fileArray)
//AdminLicenseManager.LicenseAssignments.patch()
}
Could you please help me with the following script? I'm getting "userID is not defined".
I'm trying to bulk modify licenses based 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"]
]
// Loop through all user provided google sheet rows and call Directy API with it
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 exiting/assigned license details here
} catch (e) {
var status = e.message
}
fileArray.push([status])
})
updateSheet.getRange(1, 2, fileArray.length, fileArray[0].length).setValues(fileArray)
//AdminLicenseManager.LicenseAssignments.patch()
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基于该视频。您是否将表的点击命名为
更新许可证
?如视频中所示的A列中的用户ID是否是? (如果您更改了电子邮件的列,是var
data
指向该列吗?)我在视频所有者的页面,他更新了代码:
如果您有疑问,请告诉我。
Based on that video. Did you rename the tap of the Sheet as
Update Licenses
?Are the user IDs in column A, as shown in the video, or a different Column? (if you change the column for the emails, is the var
data
pointing to that column?)I searched on the page of the owner of the video, and he updated his code:
Let me know if you have questions.