0

I have the following issue:

'I have a Google Sheet that contains copy information that is used in an app, when the app is modified by the copy person, I would like tor receive an email so I know to update the strings used inside of the app.' There are other non-automatic ways to achieve this, but the copy person knows google docs really well, and sometimes doesn't remember to notify me of changes, or 'insert other reason here'.

At any rate, I've created the function that generates a set of strings I can paste into Xcode and run the app. The only manual part is now running the function and getting the output into Xcode. The output is stored in a separate sheet of the same document. (Newest copy at the top).

The technical question / point of this post, how do I take this to the next step of emailing me so I can make the changes to the Xcode strings file?'

I am open to suggestions / other thoughts as I'm trying to iterate on this and I feel like once I get this script to run whenever the copy person updates the sheet, I will be good for some time.

Here's where I'm at:

I tried searching through Google's documentation, SO, and other sites, and found the following:

How to access revision history of a spreadsheet using GAS?

https://code.google.com/p/google-apps-script-issues/issues/detail?id=394

stackoverflow_com/questions/10584528/documentlist-api-and-gas-how-to-marry-them

sites_google_com/site/scriptsexamples/new-connectors-to-google-services/driveservice

productforums_google_com/forum/#!topic/docs/zty8X8Pkwbs

(the above are not links as my reputation is insufficient to post more than 2 links at this time).

All of these sources suggest there is a way to potentially solve this problem, but it's quite a task for something as simple as seeing 'is the last editor someone who's changes should cause this script function to run'.

My thoughts were to have my function run whenever the sheet is edited, and so long as the last modifier is the copy person, then run, otherwise, do nothing.

I may also be missing a small detail/quirk that could prevent what I want to achieve from even being possible. Hoping to find some insight / answers through this post.

Rubén
  • 34,714
  • 9
  • 70
  • 166
dslowin
  • 31
  • 3

1 Answers1

0

A quick solution would be to have your 'copy person' create a bound script in the spreadsheet with something like:

function myFunction() {
  var user = Session.getActiveUser().getEmail();
  if(user =='user-email'){
    MailApp.sendEmail('destination-email', 'subject', 'test trigger: ' + user);
    }
}

Run the function just for testing and to grant permissions.

Then he will have to create a Trigger by going to the menu "Resources -> All your triggers". Then click on "No triggers set up. Click here to add one now." Select the name of the function. Instead of time-driven, select "From Spreadsheet" Then select the event "On edit" and save the trigger.

Now, the 'copy person' should modify the spreadsheet just to test that the email is sent.

Keep in mind that with this approach, every single modification made by the 'copy person' will trigger the event and you will receive a new email.

Gerardo
  • 3,460
  • 1
  • 16
  • 18
  • Thanks for this quick solution! I may go this route in spite of the plethora of emails I'll be receiving. At the moment, I think there will be periods of many updates follow by lull periods, so hopefully that helps :). – dslowin Oct 29 '15 at 03:03