function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jovajova 

APEX Trigger to Write to Google Spreadsheets

Hi All,

 

I have the following requirement.

 

I want a TASK trigger (AFTER UPDATE) to execute a code that will write the Activity Type to a Google Spreadsheet in my Google Enterprise Account. 

 

Since this trigger will fire off any time a user records an Activity, I want the code to authenticate using a general Google account to write to this spreadsheet.

 

How can this be accomplished? The tutorials online are not helpful. As they do not cover Google Spreadsheets API inside Triggers. 

Best Answer chosen by Admin (Salesforce Developers) 
MandyKoolMandyKool

Hi,

 

For your implementation the first thing is that you cannot call a webservice from trigger synchronously. 

So in order to call the google spreadsheet api, you will need to write a seperate class which will be having an asynchronous method (with annotation @future). For more information about this check this BLOG

 

Now from this class you will have to call the google spreadsheet api. I dont know much about google spread sheet api, but I have read that for authentication we can use HTTP requests. APEX does have HTTP, HTTP REQUEST and HTTP RESPONSE classes. So for your scenario you can use them.

 

Hope this will give you a head start in what you are doing, but yes definately this not as simple as it looks :)