1

I have a script project in which some "padlocked" .gs files are shown. I can't edit or delete them.

I need to use those files, but the person who locked them is unavailable.

I was trying to unlock the files using methods from the class LockService but it doesn't seem to work that way.

How do I "unlock" these files so I can edit them?

Malekai
  • 4,765
  • 5
  • 25
  • 60
kiki
  • 199
  • 4
  • 20
  • There is a `setOwner()` method of a file in the DriveApp class. You could try: `DriveApp.getFileById(id).setOwner(emailAddress);` Also see the updated answers to post: [Transfer Ownership of File](https://stackoverflow.com/questions/10796464/transfer-ownership-of-a-file-to-another-user-in-google-apps-script) Even if you can't edit or delete those files, if you can copy the content, then you could copy the content out to another gs file. You might need to change function names in the copied code. – Alan Wells Mar 12 '19 at 00:19
  • The `getScriptLock()` method is part of the LockService class, which is used to prevent multiple instances of a section of code from running at the same time. It is to deal with concurrency problems. It doesn't unlock an inner gs or html Apps Script file. If you are seeing a padlock on the files, then you don't have edit access to the file, which is controlled through file sharing. If you have VIEW access to an Apps Script file, then you can click FILE, Make Copy, and the copy of the file will be owned by you. – Alan Wells Mar 12 '19 at 00:20
  • Thank you Sandy. There is a padlock indeed and I am the owner of the file. But what's the way to set up this padlock? Even thought I am the file owner I cannot remove it. – kiki Mar 12 '19 at 11:14
  • 1
    Sounds like the script project associated with the container is not yours. You can view more info about it in the G Suite Developer Hub at https://script.google.com . If it is a standalone script file, you should be able to access information about the project using the Google Drive API. Otherwise you are limited to the Apps Script API. – tehhowch Mar 12 '19 at 14:19
  • 2
    I figuered it. The padlock doesn't point to actual files withing this script. There is a library in a standalone script containing these files. When I use debugger it reaches these files from a standalone library and they are shown within the script with a padlock. So padlock simply means that those modules are from a separate script file! So it's not a lock. – kiki Mar 12 '19 at 14:21
  • I nandled it by creating same modules withing the script and simply renamed few functions. So I am able to use debug for all my route. – kiki Mar 12 '19 at 14:23
  • Thank you, I edited my question and added my own answer)) – kiki Mar 12 '19 at 19:06

4 Answers4

3

I figuered it. The padlock doesn't point to actual files withing this script. There is a library in a standalone script containing these files. When I use debugger it reaches these files from a standalone library and they are shown within the script with a padlock. So padlock simply means that those modules are from a separate script file! So it's not a lock.

I handled it by creating same modules withing the script and simply renamed few functions. So I am able to use debug for all my route.

kiki
  • 199
  • 4
  • 20
0

Unfortunately, only the owner of the file or an admin of your domain (if you're using G Suite) can do that.

contributorpw
  • 4,739
  • 5
  • 27
  • 50
  • I am the admin but all the code was done by the other developer who's gone now. And I don't have access to the locked file therefore cannot use releaseLock() method. And it seems to not working from a different file. – kiki Mar 11 '19 at 21:02
0

I had the padlock appear on two projects I own, and am the only editor of, without understanding why they first appeared. They appeared on my work laptop but not my home laptop. At work I'd been signed into one browser window with both my work and personal accounts. When opening the google sheet that contains the script it opens signed in as my work account. However, when opening the script from the sheet, the script opened but signed in as my personal account (that also has access). I guess this shouldn't really happen but it did. The solution was simple though, I just had to use the drop down to select my work account, which opened a new window for the script without a padlock and I was able to edit as normal. Was quite confused for a while... phew!

Murray
  • 1
  • 2
0

I had the same problem. As it turned out none of the above fixed it although similar but different to the other person who fixed his. In my case i have multiple chrome users on a single machine. I log in at the browser level.  I was in the browser for user A who also owned the file. When I opened up the bound google script project attached to the gooogle sheets file, it opened up as it should but locks were on each tab. I was confused for about 10 minutes.

In the upper right corner of the interface, there was a drop down that was showing User B email address even though above that, at the browser level I was clearly in the browser of user A. I clicked that drop down and changed to User A and the locks disappeared.  It seems they have an odd way of managing users on these gsp's that subverts the browser level user login. 

bryanp
  • 271
  • 3
  • 9