Can I have multiple toasts in GAS? - google-apps-script

I am coding an application for Google Sheets and when searching for duplicates in a sheet I want to inform the user. But the duplicates appears quite one after the other and it seems to me that there is only one toast displayed at a time. I was not able to find any way so the older ones would stay.
Is there a way to solve the using toasts? Or could you recommend any other solutions?

Related

Add one year to existing Google sheet strings

I have a google sheet that I use to keep track of my income/spends within my (one-man) company. One could argue that google sheets isn't the best tool for that, but it works best for me considering a number of reasons.
The only real problem is when I prepare the document for a new year. I have a lot of formulas calculating all sorts of things, and usually I just change the year for each and every one manually. But I'm wondering if there is a easier way to to this, some kind of "add one year to all dates in this sheet"-script.
The formulas aren't pure dates, but with a lot of other information in them as well. I post an example of how they could look below.
I don't know much about coding, so perhaps this is impossible due to whatever obvious reasons for you programmers, but I thought I might as well ask since I rather not spend my Christmas updating all million dates by hand (exaggerating but you get it!).
How do I change the following formula to be year-independent?
=(SUMIFS('Händelser'!$I$4:$I$101;'Händelser'!$K$4:$K$101;">=200101";'Händelser'!$K$4:$K$101;"<=200131")+$D$6)-(SUMIFS('Händelser'!$Q$4:$Q$101;'Händelser'!$S$4:$S$101;">=200101";'Händelser'!$S$4:$S$101;"<=200131")+$D$7)
Another example of formula:
=(SUMIFS('Händelser'!$G:$G;'Händelser'!$E:$E;">=200201";'Händelser'!$E:$E;"<=200231"))/20
Thanks!
Never mind, I just realised one could "search and replace" in google sheet, and have it search not only through the text written out but also through the formulas behind it. I just searched and replaced "=20" with "=21" and it all worked out nicely.
Have a nice day!

Google Forms - Take (Long) Existing Form and Add Answer-Based Page Navigation Using Script

I used scripting to create a Google Form with 200 + pages (generally only one question per page, though) and now need to add the branching logic to it. By the way, the new Forms gets really slow with this many pages.
Anyone know if I can use (Google) Sheets together with Forms and a script to create answer-based branching logic? I would envision Column A would be the question numbers and columns B-n would be used to point to question numbers based upon the answer. If needed, I could repeat the answer value in this exercise.
Assuming setChoices along with item.createChoice can do this.
Thanks

Google sheets import macros on multiple spreadsheets

Google recently added a feature where you can create custom shortcuts by linking it to Google App Script code. It seems pretty good and useful, except it seems the macros need to be setup spreadsheet by spreadsheet instead of in general across all spreadsheets.
I don't know about you guys, but I have multiple multiple Spreadsheets... close to 1,000 Spreadsheets that I edit sometimes. It would be impossible to import the macros one by one spreadsheet. Does anybody know how to do it for the "environment" as opposed to just one spreadsheet?
Seems like a great improvement for Google sheets, but kinda useless for me because I use so many spreadsheets.
Edit: I want to be able to write one macro and use it in any spreadsheet. I'm confused on whether this can be done because on one hand I read the docs and it said macro can't be distributed, but on the other hand other people have said you can do it by using GAS.
One of the comments below is absolutely correct, it is like the personal.xlsb excel workbook concept. In my opinion, shortcuts are useful only if they work all the time, it is a habit thing. It only is useful when it is consistent.
Google built-in shortcuts are useful because they work across all spreadsheets. If you had to set it up for each individual spreadsheet, I bet you no one would use them.
I wish google build in a developer mode or something that make them work for each spreadsheet without doing anything. I understand there are security concerns. But Google can figure it out.
If someone knows how to do it with GAS please post.

Getting a list of active file viewers with apps script

I've been googling for a while but have come up with no results that tell me I can't, but no results telling me I can.
What I'm looking for is a way in apps script (or anything in their .NET/Java/Python...API) to give me a list of people who are actively looking at the sheet when I ask. I tried getViewers but it gives me a list of all people with access, not the ones looking at it currently. If I wanted to do some data manipulation but didn't want to do it when people where in the file, or if I wanted to save the user emails of people who were in the file. It seems like it's part of analytics but I can't find anything that does what I want.
We have a working version that does some on open magic/button script trigger but this requires the user to authorize and would like to improve the process and remove the authorization step.
Anyone know a way to pull the list of people who are currently viewing a sheet/doc/slide?
It seems that this is not yet supported in Google Apps Script. I've been searching for this feature but unfortunately can't also find anything related. (Someone please correct me if I'm wrong or missed something related to this.) You're right that you can get the list of viewers but not the ones currently looking. I guess you can file a feature request for this.
If there is functionality missing from Apps Script that you would like to use, you can file a feature request on our Issue Tracker. Please describe the specific functionality you would like to see added, as well as reasons you think it's important. If possible, include specific details about your use case and the new opportunities the feature would allow for.

Workflows with google app script

Hello I'd like to know if google app script/google forms/google spreadsheet is a good way to achieve the following. (Similar to previous posts on google scripting, i am struggling a bit to understand the 'landscape' of coding problems that these google tools are good for):
A cohort of N players (could be hundreds) is asked to click a link to a web page where they enter a player id
Once the id is entered they see a message that asks them to wait until all the cohort has entered their id, and a scenario and a question (text).
Once everyone has entered their id players are paired at random and can answer the question by simply selecting a number from a drop down menu (e.g. 1-21)
The numbers given as answers are then scored according to a simple payoff matrix and each player is presented with an outcome based on the difference between the numbers they submitted as answers.
The game then repeats i.e. the players are asked the same question, and paired randomly again (they shouldn't need to re-enter their id)
What I want is a simple way to create this workflow/process/game, and a simple way to monitor the progress of the game. Something like a google form for the questions and answers and a google spreadsheet where the data is visible by the researchers.
What I don't know is whether app script and google forms/spreadsheets can be used to setup this process/workflow.
Forms + spreadsheets would also be neat because there are many versions of this basic game/process/workflow in economics i.e. different scoring matrices and questions.
I don't think you can do this in Forms, as it is not all too dynamic (not too sure), but you can easily achieve this with HtmlOutput.
You'll have to setup a linking sheet, it will store everybodys answers, and you'll constantly check this sheet for new values with setInterval to check periodically, and google.script.run to retrieve the info.
Also, this platform is not the fastest or most suitable (I don't know an alternative), but it's totally doable.