0

I am running this code in sequence editor o google sheet. I need the script to run seconds after the spreadsheet is modified. It works but it the delay function is not taking it. what is my error? thanks!!!

 function myFunction(e) {
  var url = 'https://exaple.com/?iwp=run&hash=abc123';
  Utilities.sleep(10000);
  var options = {
 'method': 'get'
 };

  var response = UrlFetchApp.fetch(url, options);
  Logger.log(response);
   }
4
  • how are you invoking the function? Commented Apr 26, 2019 at 3:26
  • The url imports the data from google sheet to wordpress. It works perfect if I copy it in the browser. The problem is that it runs before the Google sheet reads the data of the new row (it brings them form) Commented Apr 26, 2019 at 3:31
  • You could use a client side Javascript timer to do this. I have one described here . It would be easy to set up a 10 second timer as long as you don't mind having a sidebar running at the same time. Commented Apr 26, 2019 at 19:16
  • thanks for your answer. I see it interesting but it can not be done without the bar? Commented Apr 29, 2019 at 1:05

1 Answer 1

1

Im not sure about delays but you could try using triggers.It can be set to do an action after the spreadsheet has been updated.

Link:https://developers.google.com/apps-script/guides/triggers/

Link:https://courses.benlcollins.com/courses/apps-script-blastoff/lectures/8427243 (There is a example here)

Sign up to request clarification or add additional context in comments.

6 Comments

Hi Adrian! I have a configured trigger when I update as the video this import but not the last row. It seems that the problem of time...
So there is already a working trigger that will run the program when data is updated in google sheets but the delay is not working?
yes exactly only it works when the trigger is configured by times, like five minutes, etc. when I set the trigger when editing or opening the table it does not work ... although a complete row is created from mysql.
Have u tried to take out the delay portion in the script,and set the trigger to happen on data change?
do you mean delete Utilities.sleep(10000);? yes. I ran this code for the first time that i tried.. and with the function configurated on edit . Do you want a screenshot?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.