1
votes

I was wondering how/if it would be possible to link a specific folder in Google Drive to a specific Google Apps user using nothing but Google Apps scripts?

Reason for this is that we create new Google Apps users with a google form and some Google Apps scripts behind it. Afterwards we want every user to have a specific company folder linked to their "My Drive"

Any tip is welcome :)

Regards,

Kees.

1

1 Answers

1
votes

Sure thing!

Provided you made a form that has a few values use this code:

function myFunction(e) {
  var username = e.namedValues.username;
  var givenName = e.namedValues.givenName;
  var familyName = e.namedValues.familyName;
  var password = e.namedValues.password;

  var user = UserManager.createUser(username, givenName, familyName, password);
  var folder = DocsList.createFolder(username);
  folder.addEditor(user.getEmail());

}

Make a trigger with the event: onFormSubmit

With kind regards,

Thomas van Latum