1

I would like to change the owner of a file in google apps script. I tried following code:

function changeOwner() {
  
  var file = DriveApp.getFileById("id");
  file.setOwner("dummy@gmail.com");
  
}

It generate an exception error: Argument is not valid. dummy@gmail.com is not a member of my organisation.

Could you help me to transfer ownership to a user outside my organisation?

Arnaud deb
  • 13
  • 4

1 Answers1

0

You are not allowed to transfer ownership of a file on your personal Drive to a user outside of your organization

If you try - you will receive the aforementioned error:

Exception: Invalid argument

ziganotschka
  • 25,866
  • 2
  • 16
  • 33
  • Is there another method to set an owner to a user outside of my organisation ? – Arnaud deb Oct 27 '20 at 06:45
  • You need to create a shared drive that you share with the other user. Move the file to the shared drive. Then, the other user can move it from the shared drive to his personal drive and thus, become the owner of the file. – ziganotschka Oct 27 '20 at 08:58