How to find which app scripts are running? - google-apps-script

I have a spreadsheet on which I have applied immediate notification on any changes. From few days I am continuously receiving notification of changes 3 to 4 times an hour with the following message:
See the changes in the Google Document "Paper-Teacher Database":
Click here
A user made changes from 5/23/18 5:39 AM to 5:28 AM (Pacific Daylight
Time)
Also the mails are at fairly regular interval, for example I received mail at
6:09 PM, 7:44 PM, 7:59PM, 8:20PM, 8:44PM, 8:58PM, 9:20PM, 9:28PM, 9:58PM, 10:20PM. 10:28PM
Since the user name is not specified, I believe the changes are being made at the owners end (thats me). Also since I am manually not making any changes, I believe some script is doing it. To the best of my knowledge I do not have any script which is time triggered 3-4 times an hour.
Is there a way to find out the erroneous script and stop it?

While signed in go to https://script.google.com/ Open the hamburger menu in the upper left corner and select “My executions” to see the list of the recently executed functions and associated projects.

Related

Apps Script get User's Work Week Settings

I'm working on a script to automatically schedule certain tasks for some users at my company. When the tasks get scheduled will be based on the user's workweek and workday, which can be customized in Google Calendar. Most of us have a M-F work week, but we have flexible schedules so for some of us, their work day may be 7-3, others 8-4, or 9-5. Some may work 4 days a week, 10 hours a day so they work Mon-Thur, 7-5, 8-6, or 9-7. That's not counting second shift, third shift, etc. I don't want the tasks to be scheduled outside of their workdays.
How can I access these settings from Apps Script?
Unfortunately, it is currently not possible to get Working Hours information through Calendar API.
Although you can query whether there are conflicting events for a given calendar/time-frame using Freebusy.query(), this method will not return a “busy” response when querying for a time-frame out of working hours.
Additionally, there is currently a new Google API in alpha called Calendar User Availability API but it currently only exposes Working Location queries not Working Hours.
More information about Calendar User Availability API on this blog post
Alternatively, you can file a new Feature Request with Google using this template

How to reload gmail add-on through background process using app-script

May i get some help on the below points where i am using app-script to develop a gmail add-on:
How can we refresh gmail add-on with back ground process?
=> Here is my case, I need to display card with multiple sections which is the process of hitting multiple apis to fetch data and to display the card. For this initially we will show a card with minimal information to the user once i get information from api, i need to update the basic cards with complete information.
How can we trigger a function on every mail thread open?
=> Currently it works once for a mail, here as explained above point need to refresh a card once we fetch the data. If not, user will be seeing same basic information card every time he opens the mail.
From above mentioned issues for point one we are trying to get solution where we can hit service for certain interval of time to check data availability and if data exists then fetch data and update cards, i mean to say need a setTimeout function kind of thing, unfortunately we did'nt found this in app script and We found sleep/waitLock functions in app-script, but my services may take little time to fetch data as it connects though multiple services so we cant make the user to wait until the whole process is to be completed. So that we will show a card with basic information required then after need to auto refresh the cards once we fetch the data. we tried of keeping refresh button for the user to click and fetch the updated data but here we are losing user experience, trying for auto refresh with out user interference to get updated information.
Need a process / solution where we can auto refresh the card with out user interference after the data available at our end instead of making user to wait until the process to be completed.
Earliest reply will be more helpful for us.
Thanks.
If a data status on a third-party backend changes as the result of a user interaction with your add-on UI, it is recommended that the add-on set a 'state changed' bit to true so that any existing client side cache is cleared. See the ActionResponseBuilder.setStateChanged() method description for additional details.
The card-based interface in Gmail Addons is an Apps Script Service.
You can interlink it with other Apps Script services as well as implement API calls - everything within the same Apps Script file.
Gmail Addons contents automatically update every time the user opens a different e-mail or refreshes his browser.
Within your Apps Script code you can install time-driven triggers to run the data availability check with a customized frequency.
Consider to install for your users an Auto Refresh extension if you do not want them to refresh the card themselves.

In Ews push notification mode, I am getting unwanted unsaved Appointment. How to get rid of them?

I am using Exchange Web Services' push notification mode. I noticed that when I "New an appointment" in Exchange, if I click "attachment" button, it jumps to Attachement page, and push a "Item" notification into the SOAP servlet right away, without me "Save" the appointment. I guess this is probably how it works. But then I need to identify this "Item" as unfinished in my code, such that I can ignore it until I received another notification when the appointment is actually saved. So far, I've tried a number of properties such as isDraft, isDirty, getAppointmentState and etc to identify this "unsaved" appointment, but none of them worked.
So my questions are:
Can I config the exchange server such that it stops pushing notification for "unsaved" appointment?
Failing to do (1), how can I identify the "unsaved" appointment? Which property to check?
Thanks in advance,
Ling
Notifications are basically just telling you that an Item has been created on the server and based on way the UI action is taking place the client is creating an item to cater for the UI interaction so you will get a notification regardless. There is no such concept as a draft appointment and then next notification you get for that appointment should be an update. Multiple notification for an appointment is something that your code you should expect and deal with if you synchronization process is going to work reliably.
One thing you can try is to look at the item that is being created with a MAPI editor like OutlookSpy or MFCMapi as that will tell you if there is a specific extended property that you maybe able to use.

Are there any hooks for user modification events in google apps?

Currently the bane of my existence is dealing with users email signatures at work, changing names, titles, departments, new users...it's all annoying. Currently I manage it with GAM and a semi templated HTML file to push changes, which works okay, but it's still a manual process. What I'm looking to do is create a small app script or app engine project that can...
detect a new or changed user
pull the fields needed to fill in their signature template
push the changes to their account
2 & 3 are no problem at all, it's #1 that I cannot find a reasonable solution to.
I had thought about using the google apps audit settings to email a specific mailbox when a new user is created, but that will only catch new users, not changes in titles and such. My only apparent option is something that runs periodically checking all the users signatures against what my script would generate and updating if needed, but that's hardly efficient and creates a potential timelapse in the waiting period meaning when people want things 'done now' (which is of course, every request), it will mean I manually trigger the job; effectively bringing me back to my original solution.
Is there any kind of user feed that contains changes available in google apps? Maybe google has a POST hook that hits a predefined URL on changes?
You can probably use push notifications for this https://developers.google.com/drive/web/push using the users.watch method https://developers.google.com/admin-sdk/directory/v1/reference/users/watch

When does Google require re-authentication?

I am using a script that sends an email whenever a user submits a form. Since the script is using my Google account to send the emails, I have to authorize it and that makes sense. However, my scripts eventually stop working (seemingly)randomly and requires re-authentication. The most recent occurrence happened today, one of my scripts requires authentication even though it states that the last edit happened 4 days ago.
Basically, I understand why I have to authenticate, but what makes me have to re-authenticate?
Scripts that use more sensitive apis like Gmail will force a reauth on every code change. Otherwise, you shouldn't need a reauth unless you use a new api, or if you start writing when in the past you were only reading (basically, if you do something beyond the scope of what was previously authorized).
Changes to the script will require you to re-authorize. And something as simple as adding a space to your code counts as a change. Many times these are inadvertent.