google-apps-script | A collection of Google Apps Script
kandi X-RAY | google-apps-script Summary
kandi X-RAY | google-apps-script Summary
A collection of Google Apps Script that I've worked on over time.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of google-apps-script
google-apps-script Key Features
google-apps-script Examples and Code Snippets
Community Discussions
Trending Discussions on google-apps-script
QUESTION
I'm attempting to merge two PDF files from Google Drive via ConvertAPI with the following code. Both pdf1 and pdf2 are file objects.
...ANSWER
Answered 2022-Mar-30 at 03:37From your showing script and your showing official document, how about the following modification?
Modified script:Please replace with your secret.
QUESTION
I am trying to send a POST request in order to receive an Access Token in return.
The documentation is as follows:
Client Credentials
This is your first route to obtain an access_token to communicate with the API.
Route : POST https://api.helloasso.com/oauth2/token
Headers
Content-Type = application/x-www-form-urlencoded
Body
client_id = Your Client Id
client_secret = Your Client Secret
grant_type = client_credentials
Solution I tried
Based on this post, I tried the following code:
...ANSWER
Answered 2022-Mar-11 at 00:25- In the case of UrlFetchApp, the default content type is
application/x-www-form-urlencoded
. - From your question and situation, I guessed that your
Body
might be required to be sent as form data.
If those points are reflected in your script, it becomes as follows.
Modified script:QUESTION
On the 19th January 2022, the CellImageBuilder class was added to the Google Sheets Spreadsheet service.
This class now allows you to import an image into a cell in Google Sheets, previously you could only add an image above the cell.
Ive been trying to use this new class to take a URL link from a Google sheet, and then create an image in the cell next to the URL. This works perfectly fine if I can hard code the URL into the script (example below)
...ANSWER
Answered 2022-Mar-03 at 20:43- This issue is filed. Add a star to this issue for Google developers to prioritize fixing this.
setValues()
is NOT working withCellImage
, whilesetValue()
does.
If/when it starts working, You need to convert each value to cellImage
using map :
QUESTION
Write a script that does the following:
- get data from sheet
- modify column to flip names from [Last, First] to [First Last]
- modify 2 columns to abbreviate company names & statuses
- write resulting data to another spreadsheet without changing the format
- add timestamp for when data copied
I can get the data BUT it writes everything back as plain text. Thus instead of dates writing out as "yyyy-MM-dd"
, they write out as something like this:
Mon Oct 19 2020 01:00:00 GMT-0400 (Eastern Daylight Time)
Expectation: screenshot of dates as "yyyy-MM-dd"
Result: screenshot of dates as whatever this garble is
I have googled extensively and can't seem to find a solution. I believe my problem is with using toString()
in the Array.map. I'm not sure how to restrict the map method to only the columns that need modifying. Right now it affects the whole array.
(I used the code from Google Apps Script for Multiple Find and Replace in Google Sheets to write this part)
ANSWER
Answered 2022-Feb-12 at 21:52setNumberFormat('yyyy-MM-dd')
is a good solution but it's a method of a Range of the sheet. Not an array.
To apply the format you need to get a range first. Something like this:
QUESTION
I currently have two google sheets.
- 1 is a master sheet in which each row contains information specific to an individual student.
- The other is a template that I hope to make a copy of and then populate with information from a specific row of the master sheet (so each student will have their own googlsheet with only their information in it.
The issue I'm having is that I can't figure out how to import an entire row all at once.
My initial attempt was based off of this idea. However, since I am trying to import roughly 1000 different cells (yes all in the same row) the script times out before completing the script for 60 students. I assume it will be faster to import an entire row instead of using "createTextFinder" to replace all 1000 references. I've also read that using a trigger may be a work around to the script timing out - but I also couldn't figure that out (yet). I'd be happy using either solution. The part of the code I believe you need to reference is below. And this is a copy of my master sheet. [update] This is a copy of the template sheet (note that I made a copy so the sheet ID won't match the code).
...ANSWER
Answered 2022-Feb-01 at 07:17I believe your goal is as follows.
- You want to reduce the process cost of your script.
- When I saw your template Spreadsheet and the source Spreadsheet, I understood that you wanted to copy the values from a row of the source Spreadsheet to the template Spreadsheet. And also, I thought that the order of columns of the copied row is the same between the source and the template. In this case,
SpreadsheetApp.create
might be used instead ofmakeCopy
. And also, a lot ofcreateTextFinder
is not required to be used. - In your script,
orderBlob
is not used. So in this modification, I removed it. - In order to put the URL and the value of
Spreadsheet Ready
, I used Sheets API.
When these points are reflected in your script, how about the following modification?
Modified script:Before you use this script, please enable Sheets API at Advanced Google services.
QUESTION
- Search Sheet for
to_replace
string.- If found, replace
to_replace
withreplace_with
. - If not found, replace
to_replace
withto_replace
// This is not needed, and causes problems (it replaces all formulas, and replaces it with a string).
- If found, replace
I would like the script to only replace cells that match to_replace
, and ignore every other cell.
Exclude specific columns in the foruma by eliminating column C from array using script from here. (only find & replace within Column B & D).
Here is the modified code I added in My Current Script...
...ANSWER
Answered 2022-Jan-13 at 08:43From teach me a better way to solve this problem
, in your situation, I thought that when TextFinder is used, the process cost might be able to be reduced. When TextFinder is used for achieving your goal, it becomes as follows.
QUESTION
In the following example I use Apps Script to schedule Google calendar events based on spreadsheet input. This code works just fine however I need to tweak it to do a small manipulation on the source sheet as well. You can see here that I filter the range to only include rows that have "Pending" value in column D (r[3]). However I need to include a line of code in the loop so that after the filtered rows are synced to my Google Calendar the same cell value in column D changes to "Scheduled" for the respective cell. I have tried following this solution but could not implement it since I am new to JS.
Google Apps Script - .setValue in cell based on for loop matching
...ANSWER
Answered 2022-Jan-07 at 17:46One simple solution is to change a bit logic of your script. Instead of using filter
use an if
statement then overwrite the whole range.
QUESTION
The resources that exist in the Admin SDK are marked as optional in the AdminDirectory interface (see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/google-apps-script/apis/directory_v1.d.ts#L1037-L1056). Why is this the case if those are all defined resources?
This is coming up because typescript checker is throwing "Object is possibly undefined" when referencing something like AdminDirectory.Domains.list("my_customer").domains
.
ANSWER
Answered 2021-Aug-21 at 04:55Bottom line: "because they said so".
In the DefinitelyTyped definitions file linked in your question, those properties have been optional since the file was created. As per your question, the directory API in the official Google Node.JS SDK does indeed declare these properties as required. Therefore, it's impossible to tell whether this was an intentional decision by the person(s) responsible for the DefinitelyTyped definitions, and if so, what prompted it.
Your best options here are to either type cast the value as Required
if you're certain that those properties will always exist (not ideal), or to create an issue on the DefinitelyTyped repository, getting clarification and/or fixing the typings for potential future users.
QUESTION
This issue has been discussed in detail here and here. But none of the scripts I´ve seen and analyzed with a great deal of attention seems to solve my problem. That´s why I am calling on all brilliant minds out there to help me.
Here are the details of my problem:
ISSUE:
My current script (see it below) sends out an html email to each recipient listed in my sheet and then set the status for each recipient receiving that html email to “EMAIL SENT” in column K. Now I want to send 3 additional html emails to each of these recipients exactly on the dates that I´ve already specified in column L, M and N for each recipient.
Example: recipient A received the first html email on 11.10.2021 (format used: day/month/year) and he is scheduled to receive the second html email on 25.10.2021, the third html email on 27.10.2021 and the forth/last html email on 29.10.2021. These dates for recipient A are specified in column L (25.10.2021), column M (27.10.2021) and column N (29.10.2021).
QUESTION:
How can I ensure that each recipient receives the additional emails on the dates specified for him in column L, M and N?
I´d really appreciate any help or hint to solve this problem.
Here is my current script:
...ANSWER
Answered 2021-Oct-22 at 14:05Since you want to send the emails for dates which are in the future, the best solution would be to use a time-based trigger. In this way, your function sendEmail
will end up running every day and by checking the current date with the dates in L
, M
, N
columns the email will be sent accordingly.
QUESTION
I am attempting to:
Have google script perform a function that inserts formulas (I think using R1C1) into Column G in this example based on column F, and using variables for the column reference in the formula. The Formula is =NETWORKDAYS. I want to ensure my function searches for the column header names instead of the number in case the columns are moved.
The formula inserted into column G would change changed which column its pulling from, depending on column F
For our example here, if Yes in Column F, Column G would have the formula =NETWORKDAYS(A2,D2) with this being input to each cell respectively in column G.
If no, the formula would be =NETWORKDAYS(A2,B2), with the formula inserted into each cell respectively in column G.
Current Issue:
- I am unsure how to code this so that the formula uses the column header name instead of a hard-coded column number reference like you would do in R1C1 notation
- I am not great with IF statements, and "passing through" items in a range (i.e. making the function move through the range), this is still a grey area for me
What I would like to have happen/End Result of script:
Current Code:
...ANSWER
Answered 2021-Oct-13 at 21:01See my comment on your original post.
However, sight-unseen and hence untested, you can try this formula (no script involved) in G1:
=ArrayFormula({"Training Days"; IF(A2:A="",,NETWORKDAYS(A2:A,IF(F2:F="Yes",D2:D,B2:B)))})
This single array formula should produce the header and all column results for active rows.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install google-apps-script
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page