简体   繁体   中英

creating account by data from spreadsheet - google apps

I am working on a simple script that creates an account in the control panel of a domain - for example Gmail - and I was looking for a function in the Google apps script that creates an account automatically on inserting data to a spreadsheet

I searched the internet and I did find this though : https://developers.google.com/apps-script/class_usermanager and the method I am using is : var user = UserManager.createUser("john.smith", "John", "Smith", "password My question is, how can I insert the parameters from the spreadsheet that I have. Sorry if this sounds a bit stupid I'm just new to Google apps script.

To read from the spreadsheet, you would use the SpreadsheetApp .

An example of reading a set of rows. (Let's say all rows).

var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();

.getValues() returns a 2D array. So you would access it by data[rowNum][colNum] . Let's say you want to add every row as a new user, you could do

for (var i in data) {
  UserManager.createUser(data[i][0], data[i][1], data[i][2], data[i][3]);
}

How would you run said script? You could put all of it inside some function ( function addAllUsers() ) and then run it from the run menu in the Script Editor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM