Reputation: 334
I have created a app in appmaker. In that there is a table which should get refreshed (i.e a particular appscript function (client-side function)should run to refresh the table) whenever any change in calendar events of a particular calendar on the current day takes place. How to set such type of trigger?
I did some R&D and found that there is something called watch function in calendar API but I'm not sure if it is useful for my problem.
By table I am referring to appmaker table widget.
If setting the appscript calendar trigger, Client refresh may be a problem. Because in my ui above the table there is a dropdown to select the calendarId which refreshes the table by running the below code:
var calendarId=app.pages.Events.descendants.Dropdown1.value;
google.script.run.withSuccessHandler(function() {
app.datasources.Events.load();
}).getTodayEvents(calendarId);
/* In getTodayEvents() current day events of the calendarId are
fetched from that calendar and stored in DB */
Can this happen from server side through trigger?
Also trigger should be based on the calendarId currently selected in dropdown. So the calendarId needs to be dynamic in the trigger.
Upvotes: 0
Views: 208
Reputation: 5253
A calendar watch requires an webhook that will process some logic when there is an event modification(create, update, delete). Unfortunately, App Maker does not yet support such a thing and here is a discussion about it Calling App Maker server scripts from outside of App Maker UI. On top of that, you would require to interact with the client side rather than the server, so definitely not.
In this case, the best thing you can do is set an interval that will refresh the ui every certain seconds or minutes.
setInterval(function(){
app.datasources.myDatasource.load();
},60000); //60 seconds
A more advanced way of approaching this would be using firebase and cloud functions. I have implemented firebase on some projects with reliable results. You can read more about firebase and cloud functions on the below links:
Upvotes: 1
Reputation: 8964
This may or may not be applicable to your use case but for non-app-maker script projects I'd do the following:
Note that this "Calendar" trigger can only detect updates to your primary calendar. Changes to secondary calendars you create will not be tracked.
Upvotes: 0