There he has a way to get all V8 scripts without having to deal one by one fastidiously?

156 views
Skip to first unread message

anne marie Gay

unread,
Mar 8, 2021, 10:50:32 AM3/8/21
to Google Apps Script Community
There he has a way to get all V8 scripts without having to deal one by one fastidiously?

Alan Wells

unread,
Mar 8, 2021, 11:28:46 AM3/8/21
to Google Apps Script Community
The Apps Script API can be used to do things with Apps Script files.
See:

There is also CLASP which can do things with Apps Script files.

What are you trying to do?

anne marie Gay

unread,
Mar 8, 2021, 1:09:38 PM3/8/21
to Google Apps Script Community

I have a classic gmail account, I run the scripts as the owner 

In short I use around 3000 GoogleDocs (text) documents which all use a library named ”biblio“ embedded in the latest version with 

All my documents load on opening


Script


function oninstall () {

   onOpen ();

 }

function onOpen () {

   library.oninstall ();

 }


I spent my library named "Library" V8

So all my scripts embedded in thousands of GoogleDocs (text) use my library named "Library" and ask me all the first time the permissions to sensitive data

Can we by does a script perform this processing for all GoogleDocs?

Currently, the Manifesto is under the old “Rhino” environment.

I have to do this work manually and laboriously !!!

Can we use a script to do this processing for all GoogleDocs?

Capture d’écran 2021-03-08 à 18.52.38.png

Alan Wells

unread,
Mar 8, 2021, 2:50:52 PM3/8/21
to Google Apps Script Community
So, you have a library that is being used in thousands of Google Docs.
And every time that any of those Google Docs is opened, there is a prompt to authorize the permissions?
Which means that you'd need to authorize the permissions thousands of times.
And obviously that's a lot of work.
Is that the problem?

You would like a way to automate the authorization, so that you don't need to do it manually?
I have not heard of a way to accept authorization automatically.
I don't believe that's possible.

If I've misunderstood your situation, please let us know.

Project Settings
General settings
Settings that pertain to the entire Apps Script project. Changes to these settings will not impact your existing deployment.

Log uncaught exceptions to Cloud logs
Enable Chrome V8 runtime
Show "appsscript.json" manifest file in editor

anne marie Gay

unread,
Mar 9, 2021, 3:37:23 AM3/9/21
to Google Apps Script Community
Thanks for your help

Also i would like a way to automate the authorization, so that i don't need to do it manually
where do I put the permissions
in the manifest of my library or in each document?

like this

Enable Chrome V8 runtime for all my googledoc

Can you help me ?

Alan Wells

unread,
Mar 9, 2021, 9:04:27 AM3/9/21
to Google Apps Script Community
The appsscript.json manifest file in the library is where the required scopes should be listed.
I don't believe that you need to edit every manifest file in all the Apps Script projects (script files) that the library is added to.
So, you shouldn't need to go into every project that the library is added to as far as the scopes are concerned.
However, every project that the library is added to has a setting for the library and the library version number in it's manifest file.
Adding a library and a version number to a manifest file is something that can be automated through the Apps Script API.
You need to know the Apps Script project (file) ID in order to get access to the particular manifest file in that Apps Script project.
As long as you can get the file ID's of all the projects that you need to change the manifest file in,
then you can write code to change the library version number and the runtime setting.
So, if you want to programmatically change a manifest file
FROM:
"runtimeVersion": "DEPRECATED_ES5"
TO:
"runtimeVersion": "V8"

That can be done with the Apps Script API.
It needs to be done with the "Update Content" method


I do have some sample code on GitHub, but it's not exactly what you need.
You can look at it, to see if it gives you any information.

You need to 
  • get all the Apps Script file ID's,
  • loop through the file IDs,
  • get the file content,
  • modify the manifest file,
  • update the new file content back to the same file.
So, in your case the source and target file are the same file.
In order to write the code that would do that, it would be work.

Actually, it would be a good add-on idea, to provide something that would loop through
a bunch of files and update all the manifest files.

There is a question on StackOverflow about programmatically editing bound apps script files.

But the answer is not correct.
Updating manifest files is something that I could integrate into a Web App.
I am working on a Web App that does stuff with the Apps Script API,  and also includes a code editor.

Also see:

anne marie Gay

unread,
Mar 9, 2021, 12:37:26 PM3/9/21
to Google Apps Script Community
Thanks a lot for the time you gives

your explanation are remarkable and accessible to beginner programmers



I found this, is it still relevant? are there any novelties since 2019
Can you give me a piece of script to change manifest file

FROM:
"runtimeVersion": "DEPRECATED_ES5"
TO:
"runtimeVersion": "V8"

of all my googledoc in a Drive directory 

Dear

Alan Wells

unread,
Mar 9, 2021, 1:25:53 PM3/9/21
to Google Apps Script Community
In order to use the Apps Script API, you will need to associate a Google Cloud Project with the Apps Script project.
The first thing to do is to create an Apps Script file that you will use to update the manifests in the other Apps Script files.
Then create a new GCP project.
Then associate the new GCP project with the Apps Script project.
I'm explaining a very general overview.
You'll need to get the details from the the instructions at:

After you have associated the GCP project with the Apps Script project, 
go to the GitHub repo at the following link:

Read through the instructions about how to get and update the manifest file.

You'll still need to get all the Apps Script project ID's.
Which you'd need to do manually.  Obviously that will be a lot of work, and I don't know whether it's worth it, 
but you may not have a choice.
Even once you have all those ID's, that list might not be correct in the future if new Doc files are adding your library.

Alan Wells

unread,
Mar 10, 2021, 8:34:40 PM3/10/21
to Google Apps Script Community
Take a look at this post also:

It has an interesting strategy.
You'd need to add a second bound script to every Doc, and then record the new bound script ID
and keep a record of it.
Then you'd have a list of all the bound script IDs that are bound to the Doc.
The problem is, I'm not sure if you'd then have two Apps Script projects bound to the Doc.
And I'm not sure how you'd delete the original one except by doing it manually.
If the code just overwrites the first bound script, or deletes it then you wouldn't have two projects bound to the Doc.

anne marie Gay

unread,
Mar 11, 2021, 4:51:56 AM3/11/21
to Google Apps Script Community
Thanks i watch this
Reply all
Reply to author
Forward
0 new messages