Auto populating Google Calendar based on Google Sheets document - google-apps-script

I've read a lot of posts related to my problem... The problem is I'm not a computer programmer and it's like reading a foreign language to me. I've tried to muddle my way through it but to no avail. I've mainly been working from this post and the links from that page.
I have a Google Sheets document with a list of id numbers and a start date and end date for treatments. I'd like to be able to run a script that will auto populate a Google Calendar with the id numbers as the event title and the treatment time frame. I don't need a start and end time, I'm only looking for dates.
I would also like to create another Google Calendar from the same spreadsheet. I have 6 columns associated with each id number - a projected date and an actual date for 3 different types of testing. I would like to be able to run another script that populates a Google Calendar with the type of testing as the event title. Again, not concerned with times at all, just the dates.
I'm using this to track an experiment I'm running and it's just a lot of information to see on a spreadsheet. It would be nice easier to see all the testing I need to do in a calendar format so I don't make any more mistakes in missing testing days or when to stop treatments.
I've been trying for 3 weeks to figure this out on my own. Let's just say, I know nothing about coding...

You should try writing a function in Google Apps script.
Get the active sheet, get range and retreive the id numbers and a start date and end date.
Then create a calender event by referring to this link.
Hope that helps!

Related

How to implement? Spreadsheet with link - Go To Link Grab Data - Update Spreadsheet Row

I am looking for technology suggestions. Or if this can be done in native google sheets (note the site I am looking to access is behind a username and password).
I have a google sheet that looks like this
birth date
link
data_element_from_website
12/31
https://something.com/3920230
1/31
https://something.com/1920238
lets say on https://something.com/3920230 there is a HTML element 123
Twice a day I want to be able to refresh the data, this could be done by going into the spreadsheet and clicking/doing something.
Can this be done?
What if https://something.com/3920230 is behind a login (authentication). Note: I could be logged in to the website in a different tab... I don't think that would make a difference though...
Assuming you have a script that you would like to run twice a day, you can use Apps Script Time-driven triggers:
A time-driven trigger (also called a clock trigger) is similar to a cron job in Unix. Time-driven triggers let scripts execute at a particular time or on a recurring interval, as frequently as every minute or as infrequently as once per month. (Note that an add-on can use a time-driven trigger once per hour at most.)
If it's just some formulae, you can change the recalculation settings to be either On change, On change and every minute or On change and every hour under the File > Spreadsheet settings menu item and clicking on the Calculation tab.
If you want to get data from public site(no login) you can use ImportXML. You can google a lot about it, for example
https://answerbun.com/personal-finance-money/get-revenue-details-in-google-sheets-using-google-finance/
If the page you want can only be accessed using login, this becomes a rather complicated task, especially using only apps script libraries (not much scraping lib support here)

Same script working differently in 2 script editors

Premise: I have not a problem with algorythms or syntax or method and so on, for this reason I apologize not to report scripts or piece of it.
But I am in a mistery.
I have a Form for booking medical appointments, filled on line by patients, that feeds a Sheet where appointments are reported. The sheet is used only by the doctor to have the view of his engagements. The form suggests to the patients a list of days and hourly slots, by a ListItem of open time intervals (i.e.: Wed March, 3 hh 11 - 11:20 am ). The sheet (triggered on submit of the form) drives the automatic update of the List Item of the Google Form, to be proposed to the next patient requiring an appointment.
One function in one script for all, it works perfectly.
Now, I would like to give the doctor the possibility to manage the table of the appointment (the sheet), editing the cells of the table itself. But so doing the List Item of the time slots in the Form has to be updated every time the table is edited (triggering on edit).
So, to the aim:
1) I took the piece of my script in charge of updating the Form, which became a new function in the same script editor as I developed the primary function. The new function works perfectly when it runs from the script editor of the Form.
2) I copy INTEGRALLY the above script in the script editor of the sheet and...a for loop does not work as expected, in any way it does not work as it does in the Form environment.
Note: every files are opened by ID and no methods are invoked on "active" file.
Thanks
Posting for documentation purposes; OP found the answer, as per their comment:
And I finally solved. It was a problem arising from the Timezone management. In facts, Guide says: "New scripts default to the owner's time zone, but the script's time zone can be changed by clicking File > Project properties in the script editor." I did, problem evaporated and I found my peace.

syncing Google spreadsheet and Google (my) Maps

I would like to synchronize a google spreadsheet with a map so that I don't have to upload everything everyday.
I found that it's possible to synch a google form to google map using Google Fusion.
See, YouTube: Syncing Google Forms with Google Fusion Tables for Crowdsourced Maps.
But I couldn't replicate the process to my situation (I guess it's maybe because the spreadsheet content is not originated from a google form and maybe the script take that into account)
I don't know much about coding scripts but automating this process would be a blast for me!!
I hope someone will be able to help me out on this
thanks a lot and have a good day
The only thing to account for this situation is the difference of form submit. The guy in the video sets up two triggers: one for onFormSubmit, and one hourly trigger for syncing whenever any manual changes are made.
I haven't looked directly over the code, but all you should have to do is modify the onFormSubmit code and trigger. Change the code to look for and update the fusion table with any new rows from your spreadsheet. And then change the trigger to your desired need, timer would probably be the best option. So every hour, or day, or run it manually after your done adding rows.
Now, if you were to edit the rows of data after they've already been updated, the hourly syncing will take care of those changes.
I could imagine that the hourly sync method could be changed in such a manner to look for rows that need to be added, could be as simple as calling the submit function.
I had the same problem but i could solve it.
A time trigger is not needed if you set the sync function at the end of the function OnFormSubmit (so "sync();" under "insertRowId(rowId, row);" Syncing takes place after each sending of the form automatically.
For larger forms I found out that you should not make a special column Location in the Fusion table. The address column should marked as Location in Fusion table. In the script properties of the spreadsheet give the addressColumn the value of the column title of the address column and the third property keeps unchanged ("latlng">Location. What happens is that the value of the adres is overwritten by "latlng". So if you have trouble to loose the original addresses, add a new column, copy by apps script the same address (that piece of script direct at the beginning of the function OnFormSubmit) and (after syncing) give the addressColumn the value of the column title and in the Fusion table marks the original addess column as Text and the new column as Location.

Google spreadsheet custom calculations using GA add-ons

You have many brilliant minds here so I hope to get some kind of help on the issue.
I have just started to use Google Analytics Add-on in Google Spreadsheet. I could figure how to retrieve data from GA, no problem here.
I've created a report what creates several sheets/tabs (populated with data from different months) and now I want to make several calculations in them (lets say to calculate trends). No problem here either. But when I want to add another sheet/tab with new month's data and run a report, all my custom calculations that I did in other sheets disappear.
Is there a way to create some kind of a template or something similar so that my sheets would save custom calculations of mine and when reports would be run again only new sheets would be added and populated, and old ones would stay the same?
Would appreciate your help!
Thanks a lot,
Ieva

Insert a date, Highlight/move a row when date is added and highlight in another sheet

Can anyone help with these Google Apps Script questions? I've never used scripts before, but I think they could solve my issues...
How do I most easily insert the current date?
Is there a way to highlight a row when the current date is added, and then move that row to the bottom of the current rows?
Is there a way to highlight a name field when it is a duplicate in another sheet?
Is there a way to highlight a row when it is highlighted in another sheet?
I would like to develop a spreadsheet to track the progress of magazine advertisers. I need to track when we receive an advertiser's information and when the ads are proofed out. (Lots of dates to insert!) Then when the ad is approved, I need to highlight that row and move it to the bottom of the other rows. (The number of current rows will be constantly changing.) Then once I receive the layout, I need to know what ads we have and of those, which are approved.
I hope someone can help me out with these questions--thank you in advance!!
Cortny!
A few places to start at regarding Events, Triggers and Spreadsheet handling:
https://developers.google.com/apps-script/understanding_events
https://developers.google.com/apps-script/understanding_triggers
https://developers.google.com/apps-script/reference/spreadsheet/
I have scripts that upon editing a row record in a particular column of that row the time it was edited and in another column the username (email address) of the user editing. This script was originally in a couple of different libraries and I tried to paste the relevant portions into a single script and generalize it to the extent possible. I have not tested as it appears here -- I hope I copied everything:
https://script.google.com/d/1qVLXiKZA8SAgOoW2BAcOCtQ2bXeCNz6oRed8bN9YOOPpvdI0HzAdxeC0/edit?usp=sharing
Since this script also accesses the user's email address it must be explicitly authorized by each user before it works properly. It is for this reason that the main functions is called onEditDelegate() that must be added manually to the onEdit trigger instead of being called onEdit(). If you don't need the username, you can remove that part and it will be easier to install the script.
You can also extend this script so that when all the necessary info is entered the script copies the content of the row, deletes it from the spreadsheet and pastes it at the bottom of the sheet.
Similarly the other points you mentioned can be achieved using triggers/events.
Good luck!