r/GoogleAppsScript • • Mar 31 '23

Guide I published a quick tutorial showing how to setup automated reminders in Google Sheets, comparing built-in notifications and Apps Script

Thumbnail
medium.com
6 Upvotes

r/GoogleAppsScript • • Mar 30 '23

Question A way to update a row on google sheet from your custom slack app?

6 Upvotes

Hi there! So I have a custom slack app that gathers information from google sheets and sends us what we need to slack. I want to add a work flow to this custom slack app that is currently sending this information from the gsheet to slack so once the notification posts to the channel you can also send information back so it updates a spreadsheet row.

For example if it brings over that we need to make a 1k payment today - it should than provide option to update the row in column “sent” or confirmation number so we can update the sheet form there versus going in and updating it separately.

I found this reference, please let me know if you have any other good ones. Thank you!

https://slack.com/help/articles/360053571474-Add-steps-to-a-workflow


r/GoogleAppsScript • • Mar 25 '23

Question How to unblock Apps Scripts?

6 Upvotes

When I try to run Apps Scripts for any script that works on other Google accounts I get this error

This app is blocked

This app tried to access sensitive info in your Google Account. To keep your account safe, Google blocked this access.

There is no option to allow access or to edit this from the pop up window. In my account security/3rd party panel the app doesn't show.

I can't run any scripts in this account.

Is there a way to 'unblock' or add App Scripts in my account manually?

Thanks,


r/GoogleAppsScript • • Mar 02 '23

Guide Article: How Levels.fyi scaled to millions of users with Google Sheets as a backend

Thumbnail levels.fyi
6 Upvotes

r/GoogleAppsScript • • Feb 11 '23

Question What are some interesting ways you’ve used 3rd party APIs in Google Apps Script projects?

6 Upvotes

I was messing with the Unsplash API today to automatically grab contextual backgrounds for slides and now I want to play with more!


r/GoogleAppsScript • • Feb 10 '23

Question two way sync google sheets and ms sql data base

6 Upvotes

Hello, it is possible to read and write into a ms sql database from google sheets... i can read the data base an get the data to a google sheet, it is possible tuu modify data on the google sheet and send it to the database to sync it?


r/GoogleAppsScript • • Jan 16 '23

Question Exception: The parameters (String,number) don't match the method signature for SpreadsheetApp.Spreadsheet.getRange.

6 Upvotes

Hi,

I just started using apps script today and i have issues with my script (i never used JS before) i'm trying to use it for google sheet and use variables in a getRange function.

But, as you can see in the title, i can't.

Here is the function i use

var i = 2
var y = 2
var spreadsheet = SpreadsheetApp.getActive();
var nom = spreadsheet.getRange(21,i).getValues();
var ctrl = = spreadsheet.getRange(3, y).getValues();
while (nom = ctrl) 
{
    ctrl = spreadsheet.getRange(3, y).getValues();
    var test = spreadsheet.getRange(8, y).getValues();
    const result = /^test/.test(test)
    if (result = true) 
    {
        var valeur var valeur = spreadsheet.getRange(8, y);
        spreadsheet.getRange(22, i).setValue(valeur)
    }
} 

Please, tell me what's wrong, i can't figure. The debugger tells me the error is in this line "var nom = spreadsheet.getRange(21,i).getValues();" i'm pretty sure there is more mistakes nonetheless.

xoxo


r/GoogleAppsScript • • Oct 29 '22

Question Ways to let users run script?

6 Upvotes

We have some scripts that do API calls to some external services. We would like to let certain groups of users access to look up things. What is best way to go about this? So far just adding a menu to google sheet where user can input the data they are trying to look up and running script from menu. Any other or better ways?


r/GoogleAppsScript • • Oct 05 '22

Guide QUESTION: Javascript before Google Apps Script?

6 Upvotes

Hi!

So I'm looking to finally buy a course to learn Google Apps Script. I had programming experience during college - Java. So I can say I have a bit of understanding regarding coding etc.

For experienced users of Google Apps Script, do I really need to learn Javascript first? Also, I was looking to learn thru Udemy. Which is the most recommended platform to learn Google Apps Script?

Thank you!


r/GoogleAppsScript • • Sep 22 '22

Question Turn each rows from Google Sheets into a line of text in Google Docs and keep formatting?

6 Upvotes

Hi everyone.

I am trying to take a worksheet in Google Sheets that contains some formatted information and export the contents of each row (all of them) into a new Google Doc file as a line of text while keeping the formatting and adding some extra features (namely bolding the first column, adding a ":" and changing the link in the sheet to a shortened word that is hyperlinked).

Basicaly the goal is to take a worksheet like this:

Book TitleReviewLink
Winnie the PoohThis book is good.www/amazon/com/1
Little Red Riding HoodThis book is bad.www/amazon/com/2
GoldilocksThis book is just right.www/amazon/com/3

And get each row entered as a line of text as such:

Winnie the Pooh: This book is good. (link)

Little Red Riding Hood: This book is bad. (link)

Goldilocks: This book is just right. (link)

I have managed to get one row to print to a new google doc, to get each row to print to its own separate doc (fun to delete 100 new files that suddenly appeared), and to reprint the table with the formatting.

However, I have not achieved my desired result.

Any advice? Pretty new to writing scripts, so I understand the logic of it all, but necessarily the best and most efficient way to write something like this.


r/GoogleAppsScript • • Sep 14 '22

Question Help With script please!

6 Upvotes

Hello, I would like to have this spread sheet preform two on edit commands. I want entry's to auto sort based on the date in column 6 and also give a time stamp in column 7 when column 6 is edited or new line is created. the two scripts I found online work fine by themselves but not together. I want them to both worth as the same time and also i want to get rid on the sheet specific criteria for the autosort function and for it to affect the whole document not just individual sheets. can anyone help me?

function onEdit(e) { var row = e.range.getRow(); var col = e.range.getColumn(); if(col == 1){ e.source.getActiveSheet().getRange(row,2).setValue(new Date()); } }

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("YM");             // SHEET NAME
var range = sheet.getRange("A2:O");                  // RANGE TO SORT

function onEdit(e)  {
range.sort([{column: 6, ascending: true}]);        // COLUMN NUMBER TO SORT
}


r/GoogleAppsScript • • Aug 05 '22

Guide Why every Google App Script developer should be using Clasp to create better solutions

Thumbnail
gavinwiener.com
6 Upvotes

r/GoogleAppsScript • • Jul 19 '22

Question How do you declare your variables?

6 Upvotes

Var? Let? Const?

I see a lot of examples using var, but my understanding is that let and const are the preferred statements for “modern” JavaScript… or so my udemy course told me.

Are there Apps Script specific reasons for var, or is it just convention.


r/GoogleAppsScript • • May 31 '22

Resolved Is this normal (multiple files turn blue/look selected)

Post image
6 Upvotes

r/GoogleAppsScript • • May 14 '22

Question Trigger a Script on Email Receipt

6 Upvotes

Is it possible to trigger a script anytime an email is received to a specific address? My plan was to have certain emails that will need to be regularly processed forwarded to "[email protected]." In gmail, I made a filter to apply a label and star those emails (using the star to tell if it's been processed yet).

I was hoping to find a way to base a trigger on a gmail label or just any email receipt if needed. This is to avoid running a script and scanning the label every minute.

This page mentions...

An installable calendar event trigger runs when a user's calendar events are updated—created, edited, or deleted.

If there's no way to trigger based on emails directly, could calendar events be a workaround. That would require figuring out how to reliably create calendar events from emails, which is an additional question.

EDIT: In case anyone finds this, I was able to activate a Google Apps Script based on a specific received email trigger by publishing the script as a web app, using a webhook call triggered by certain emails with a free Zohomail account, have emails labeled as noted above in Gmail and forwarded to the Zohomail account.

If you just need the email as a trigger and don't actually need the email contents for any processing, then you could just skip the forwarding part and send the email to Zoho directly.


r/GoogleAppsScript • • May 12 '22

Question Apps Script challenge? Anyone got an interesting challenge for the community?

6 Upvotes

I had a couple Ideas myself, but wondered if anyone had an idea for an interesting challenge for an apps script based solution / tool.

I had an idea for having app script run:

  • Endpoint Management admin/client

  • Scrum management (have ds/retro/review/planning managed centrally)

  • Corporate message board (but more stack overflowy)

Now I know those things are probably deployable as an open source / free to use set of tools but really I'm just looking to see how Apps Scripts could be leveraged in general and see what obstacles present themselves. Super open to having any suggestions!


r/GoogleAppsScript • • Apr 28 '22

Question Is this possible? any freelancers willing to write the app script If it is?

6 Upvotes

I work as a Project manager for a construction sub contractor. I issue about 5 to 10 purchase orders a day via email.

The process currently goes something like this.

Send material list to vendor.

Vendor emails back pdf quote.

I hit reply and type in the purchase order # which is 2 parts.

PO#124-987

124 is the job #. 987 is the cost code.

The jobs #'s I copy from notes on the side bar. The cost codes I have memorized.

I then copy the po#.

Open the PDF in Gmail.

Then click to open it in the Adobe app and paste the po# into it with the text tool then print it for the person that pays the bills (she's old school have to print them for her) Then close that and send the reply with the po# back to the vendor.

I would love to be able to hit reply and open a template. The template would have a drop down for the job#, the cost code and then for instruction including deliver to and an address or we will pick up.

I am not tech savvy enough to know if this is do able.


r/GoogleAppsScript • • Mar 01 '22

Question Experienced Excel VBA programmer trying to make the move to Google Sheets/Apps Script

6 Upvotes

I have a lot of experience working in Excel/VBA but am looking to make the move to Apps Script to automate Google Sheets.

In Excel VBA I can set/get various properties of a workbook/worksheet/range without having to first activate the object. For example, I can write

Workbooks("Book1.xlsx").Worksheets("Sheet1").Range(Cells(2,1)).Value = 1

to set the value of cell A2 to 1 without having to first select cell A2. Similarly, I can read the value from cell A2 and set it to a variable without having to select the cell

dim myVariable = Workbooks("Book1.xlsx").Worksheets("Sheet1").Range(Cells(2,1)).Value

Is this possible in the Google Sheets? Looking at the documentation it looks like the methods all involve setActiveWorksheet and setActiveRange. Is there a way to reference a workbook/worksheet/range without having to select it?

Thank you for any help you can provide. My apologies if I'm overlooking something obvious.


r/GoogleAppsScript • • Feb 23 '22

Unresolved Is there a way to virtually push 'enter' for a cell? Or maybe activate another so the previous closes and enters the input before a function runs.

6 Upvotes

I have one cell with a value. I have a button next to it that takes that value.

Now the 'problem' is that I consequently click the button before I press enter on the cell. This makes it take the previous value and not the one in the input bar. if previous was X and input is Z it would still take X until I press enter in the cell.

I tried google and using activate() but that does not 'enter the input'. Anyone has a clue?


r/GoogleAppsScript • • Oct 06 '21

Guide Clean Inbox: Mark Unimportant and Unread as Read after some time

6 Upvotes

Posting here for anybody who spends more than 10 minutes a day cleaning out their email. This simple script will do it for you while you're sleeping. Enjoy.

function auto_mark_everything_else_as_Read() {  
var delayDays = 2 // Enter # of days before messages are marked as read   
var maxDate = new Date(); 
maxDate.setDate(maxDate.getDate()-delayDays);    
var threads = GmailApp.search("-label:important label:unread ");
for (var i = 0; i < threads.length; i++) {
console.log(threads[i]);
var subject = threads[i].getFirstMessageSubject();
console.log(subject);
if (threads[i].getLastMessageDate()<maxDate){ 

threads[i].markRead();
    } 
  } 
}


r/GoogleAppsScript • • Sep 22 '21

Question Looking for GAS "Cool scripts" library

6 Upvotes

Hello all. Was wondering if we have - or should have a place to upload and showcase cools scripts or projects we have created.


r/GoogleAppsScript • • Sep 09 '21

Question Approach when GAS project gets too big

6 Upvotes

Hi All,

Over the past 3 years, I have built an application using GAS for my small business. It started off as a few little scripts and has accidently grown to be an application with a mySQL database and about 30 or so web pages which perform various functionality. Essentially a client database with a whole bunch of data and the users can go and automate the creation of all sorts of Googler Docs - various reports and contracts etc. The users love using it and it is worth it's weight in gold in terms of time saving. I have cobbled together the scripts using the built in JS editor and use JQuery/Bootstrap etc . I have enjoyed using it but

  • I am about to embark on a doubling of the functionality (maybe even x3)

  • Some of other people I am friends with would like to start using it in their companies

  • I sometimes find it tricky to debug

So I am thinking GAS has reached it shelf life for this app and I want to migrate it to an Industry Standard dev stack and make it into a multi-tenanted application so other companies can use it also. Perhaps they will pay me some money if they like it.

Ideally I would like to keep the system in the Google Cloud for simplicity sake. I am not so worried about having to pay a bit extra to do this (as the MySQL currently costs me ~$20 per month). I would prefer to use a platform where I need to do the least possible to maintain it's upkeep and as much as possible it is looked after for me.

So my research points to using possibly Google App Engine. I would hook that up to my existing mySQL server but would need to rewrite the logic/backend/frontend code. If I need to pay someone to help me, then it would use fairly standard languages like Go or Java and I could use a nice clean UI framework. I would need to think about if other companies used it, would it hook into their google Docs/Drive or would I just store everything on mine and it gets shared with them.

Has anyone done anything like this before and how did it end up?

Do you think I am on the right track?


r/GoogleAppsScript • • Aug 01 '21

Question How to add Gmail emails to Google Calendar?

6 Upvotes

Hi all,

I'm not a programmer or a software developer, I don't really know how to code in Javascript or Google App Script, but I'm trying to learn and hope someone can help me out here.

I found the following code online but can't remember where I got it from:

function gMailReminder() {

var reminderLabel = "GReminder", //Substitute your label here

calendarName = "Mobile Calendar", ////Substitute your Calendar name here

reminderDuration = 2, //duration in hours

label = GmailApp.getUserLabelByName(reminderLabel),

threads = label.getThreads();

if (threads.length > 0) {

//get calendar by name

var cals = CalendarApp.getCalendarsByName(calendarName);

var now = new Date().getTime();

for (i in threads) {

cals[0].createEvent(reminderLabel + '- '+threads[0].getFirstMessageSubject(),

new Date(now+(60000*60*reminderDuration)),

new Date(now+(60000*60*reminderDuration)), {description: threads[i].getPermalink()});

}

//Remove the label from the mails to avoid duplicate event creation on next run

label.removeFromThreads(threads);

}

}

The script apparently searches for any emails with a specific label (in this case "GReminder") and add those emails into your calendar. I tried to set this up but I'm getting the error message:

TypeError: label.getThreads is not a function

I've tried to modify it but couldn't get it to work. It keeps throwing the same error message.

My Gmail definitely has that "GReminder" label created and I have applied it to a few emails, as a test.

My Google App Script is running using V8 Runtime.

Furthermore, the code searches for the label "GReminder" and then removes that label at the end of the script. I'd like to modify this so that the script searches for GReminder in Gmail, then adds a new GReminder-Processed label to it (to show that those emails have been "processed") and then the next time it runs again, it will skip emails with GReminder-Processed. I've only gotten the part of creating the labels sorted (I think), but can't figure out the rest...

function getOrCreateLabel(labelName) {

var label = GmailApp.getUserLabelByName(labelName);

if (label == null) {

label = GmailApp.createLabel(labelName);

}

return label;

}

var label = getOrCreateLabel("GReminder - Processed");

thread.addLabel(label);


r/GoogleAppsScript • • Jun 21 '21

Question Why is there a lack of structured courses on edx/Coursera etc?

6 Upvotes

I know there are alot of good YouTube channels which shows many interesting use cases like user forms etc. There is also a udemy course which is relatively decent (but not as comprehensive).

Outside of that, I am just curious why is there such a lack of structured courses on edx/Coursera/datacamp etc for GAS?

Is it just because it is JavaScript based, and the assumption is once you learn JavaScript, you would understand GAS?