Forums >> Programming >> Proof of Concept (POC) >>
Implementing the Google Calendar Log


Implementing the Google Calendar Log

Implementing the Google Calendar Log

We wanted to put together a unique way of keeping a log of posts, replies and edits on the system and thought it would be a good idea to use the Google Calendar addon for our GreenTools for Google Apps (G4G) application.

The first thing we did was create a Google Calendar specifically for this project.  That was easy enough and doesn't need to be documented.  

The next step was to get the ID of that calendar as well as set it up in G4G.  This was done using the G4GLSTCAL (List Calendars) command.  This will list all the calendars available for our Google ID and we can find the proper ID to use for the rest of the application.

The next thing we needed to do was write a program that could be called passing in an action (ie, edit, reply or add) an a thread ID.  Each message on the system has a unique thread ID, so once we have that we should be able to get any other information we need.

We chose not to make a subprocedure out of this.  Mainly because we were going to be submitting the call to the program so that when a message is posted or updated, the time it took to add the calendar event wouldn't be inline with the actual posting.

As mentioned our program accepts two parameters, a thread ID and an action.

Once we have those items, we query the thread file using the thread ID and build our calendar event.  A portion of the ADDCALEVT program is as follows:

calendarID = '';           
eventSubject = '[' + %trim(inAction) + ']:' + %trim(SUBJECT);                  
eventDesc = 'Thread ID ' + %trim(THREADID) + ' had the action ' +              
           %trim(inAction) + ' performed by ' + %trim(AUTHOR) + '.  ' +        
           '' +                
rc = #g4gcal_setValue('id':'');                               
rc = #g4gcal_setValue('calendar_id':calendarID);                    
rc = #g4gcal_setValue('event_title':eventSubject);                  
if (inAction = 'edit');                                                   
  eventDate = EDITDATE;                                                   
  eventDate = POSTDATE;                                                   
rc = #g4gcal_setValue('start_date':%char(%date(eventDate):*USA0));        
rc = #g4gcal_setValue('start_time':%char(%time(eventDate):*HMS0));        
rc = #g4gcal_setValue('end_date':%char(%date(eventDate):*USA0));          
rc = #g4gcal_setValue('end_time':%char(%time(eventDate):*HMS0));          
rc = #g4gcal_setValue('event_description':eventDesc);               
rc = #g4gcal_addEvent(eventID);                                     

Now we see why we needed the calendar ID.  When we add a calendar event we obviously need to know the ID of the calendar to add it too.  So, we set that, as well as a few other things (start time, end time, event title and event description). 

When we finally call the #g4g_addEvent() procedure an event should be added to our Google Calendar.

Now, this program is actually called from the program that adds or updates posts on this page, like this:

      newThreadID +                                   
      ''' ''edit'')) ' +                              
      'JOB(GBFCAL) JOBQ(*LIBL/QSYSNOMAX)';            
callp(e) #QCmdExc(QCmdCmd:QCmdLength);                

Depending on if it's an edit, reply or add the appropriate value will be passed to the ADDCALEVT program.

Last edited 07/27/2015 at 07:31:27


Copyright 1983-2017 BVSTools
GreenBoard(v3) Powered by the eRPG SDK, MAILTOOL Plus!, GreenTools for Google Apps, jQuery, jQuery UI, BlockUI, CKEditor and running on the IBM i (AKA AS/400, iSeries, System i).