I'm trying to add editors and viewers to a Google Doc using Google Apps Script. The documentation of addEditors() says that:
Adds the given array of users to the list of editors for the Document.
I can't figure out how to configure or use an array for this. The array is determined by values passed from a different script file.
Well, without any code to start with you need to do something like the following:
function addEditors() {
var emails = [
'john#example.com',
'steve#example.com',
'bill#example.com'
];
DocumentApp.getActiveDocument().addEditors(emails);
}
Arrays are a variable type in Javascript that you need to know to get started with Apps Script.
You can read more about arrays here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
Or get some practice at FreeCodeCamp: https://www.freecodecamp.com/challenges/store-multiple-values-in-one-variable-using-javascript-arrays
Good luck.
Related
I have a google drive sheet that I am trying to load data. In selenium, I can go to the page and wait for a second then parse the page. Is there anyway to wait in a similar manner?
I am trying to get the data from this table :"https://www.cboe.com/delayed_quotes/vix/future_quotes/"
=IMPORTHTML("https://www.cboe.com/delayed_quotes/vix/future_quotes/","table",1)
returns
N/A
Imported content is empty.
importing JavaScript elements is not supported in google sheets:
I believe your goal is as follows.
You want to retrieve the table in the site of the URL https://www.cboe.com/delayed_quotes/vix/future_quotes/.
Issue and workaround:
When I saw the HTML data of the URL, it seems that your expected table is not included. But, I notice that the table is created by Javascript using the values retrieved from the API. So, in this answer, I would like to propose directly retrieving your expected values from the API. In this case, the retrieved value is JSON data. So, I would like to propose using a Google Apps Script as a custom function.
Sample script:
Please copy and paste the following script to the script editor of Spreadsheet, and save the script. When you use this script, please put a custom function of =SAMPLE() to a cell. By this, the values are returned.
function SAMPLE() {
const url = "https://www.cboe.com/us/futures/api/get_quotes_combined/?symbol=AMT1&rootsymbol=null";
const res = UrlFetchApp.fetch(url);
const obj = JSON.parse(res.getContentText());
const header = ["symbol", "expiration", "last_price", "change", "high", "low", "settlement", "volume"];
return obj.data.map(o => header.map(h => o[h]));
}
Testing:
When this script is tested, the following result is obtained.
Note:
This answer is the current answer. When the specification of the site and the API is changed, this script might not be able to be used. So, please be careful about this.
References:
Custom Functions in Google Sheets
fetch(url)
I am trying to use the API to return data from the Chagrin Falls station in Ohio. I can get the data from the website so I know there is data, but the API does not return any values.
I have a valid token and the examples in the documentation work, but if I try any to alter the examples in any way I get nothing back just any empty json object {}.
Example I am trying to use:
https://www.ncdc.noaa.gov/cdo-web/api/v2/data?datasetid=GSOM&stationid=GHCND:US1OHGG0014&units=standard&startdate=2020-08-01&enddate=2020-08-01&limit=1000
Data from the website:
https://www.ncdc.noaa.gov/cdo-web/datasets/GHCND/stations/GHCND:US1OHGG0014/detail
I don't exactly know how you are going to achieve this since you haven't told us what programming language you are using. However, with python I use a module called urllib to extract raw html data from a url that can be seen from the browser using ctrl+u.
Sorry this will be a super newbie question.
In the default.ctp layout file, towards the beginning there are two lines.
$cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework');
$cakeVersion = __d('cake_dev', 'CakePHP %s', Configure::version())
I've found the function for __d here which says it "Allows you to override the current domain for a single message lookup." I don't really understand what it means at all.
Additionally, I was able to do the same thing without throwing any errors by simply replacing the lines with
$cakeDescription = 'CakePHP: the rapid development php framework';
$cakeVersion = 'CakePHP ' . Configure::version();
Its used for making your application multilingual.
You can use the command Console/cake i18n extract to extract all the text strings(which is the second parameter in __d()) into a pot file, which you can then translate.
See this for more information about __d() https://book.cakephp.org/2.0/en/core-libraries/internationalization-and-localization.html#internationalizing-cakephp-plugins
And see this for more information about extracting the strings into pot files
https://book.cakephp.org/2.0/en/console-and-shells/i18n-shell.html
I'm using google drive api and trying to search for files that have a property.
Is it possible to do something like this properties has { key='NoteId'}. I just want to find files that have the property. I don't know the value so I can and don't want to search by value. This is php google app engine code.
You must provide something like this:
"properties has { key='additionalID' and value='8e8aceg2af2ge72e78' and visibility='PRIVATE' }"
as described in Search for Files to the q parameter in drive.files.list.
I'm currently making a bilingual Expression Engine 2.5.2 website. I'm using this technique to create the two langues, which works perfectly.
I have created a {country_code} global variable in the two index.php files which allows me to detect the current language.
Using this technique, I have no problems to get language-relative data when accessing an entry. My only concern is that I apparently have to privilege a language-specific "clean" URL.
Example entry:
{entry_id} = 123
{title} = My test article
{title_permalink} = my-test-article
{name_fr} = Mon article
{name_en} = My article
If I request http://www.example.com/index.php/en/blog/articles/my-test-article, I expect to to find, in english, "My article" using the template articles in the blog template group.
Everything is fine, but the french translation is accessible when requesting http://www.example.com/index.php/fr/blog/articles/my-test-article. The correct translation of the URL should be http://www.example.com/index.php/fr/blogue/articles/mon-article-test.
Anyone encountered a problem like this? Any solutions via extensions or modules?
I believe the Transcribe module solves this by both providing the ability to translate template group and template names, and having you create a separate entry for each language and piece of content in your site (hence, you have two separate URL titles). But that means buying into their entire methodology for a multi-lingual site.
Myself, I usually just stick to using the entry_id instead of the url_title, and live with the template names being in the primary language.
The best way I found to achieve this is by embedding templates with segment translations, duplicating template groups and duplicating channels.
In the blog/articles template:
{embed="shared/.head" segment_2_translation="blogue" segment_3_translation="articles"}
In the blogue/articles template:
{embed="shared/.head" segment_2_translation="blog" segment_3_translation="articles"}
In shared/.head template:
[...] {if lang == "fr"}English{if:else}Français{/if} [...]
And then you can create a Articles (FR) and a Articles (EN) channels, and each will have their unique URL titles. You can also add a relationship custom field for each channel to associate an entry with it's translation.
It feels messy, but it is the only way I could make it work without modules, plugins or whatnot.