-2

I have configured to fetch the data on every 1 min from investing wesite.

enter image description here

The table data is fetching from website. while trying to update date when 15 minutes status D column change to either strong sell or strong buy time on time and date column the functions are not working. please find below requirement.

1) I need to update time and date in G column when D column update from the website either Strong sell or strong buy. 2) once the time and data updated if the time and date less then 1 minute then need to get email alerts.

I have tried functions on the table but not working. kindly help me on this why the functions are not working .onchange .onedit.

I am using below query but i am not getting alert.

function getData() { 
  var sheetName = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Main"); 

  var queryString = Math.random(); 
  var cellFunction = '=IMPORTHTML("https://www.investing.com/technical/commodities-technical-summary","table",4)';
  var datetime = Utilities.formatDate(new Date(), "IST", "yyyy/MM/dd HH: mm:ss");
    sheetName.getRange('A1').setValue(cellFunction); 
  sheetName.getRange('g2').setValue(datetime);
}

function sendNotification() {
    var sheetName = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Main");   
  //if("D13" == sheetName.range.getA1Notation() || "D12" == e.range.getA1Notation()) {
    if("C13" == "Strong Buy" and "h13"=now() diff 1 minutes) {



  //Define Notification Details
      var recipients = "[email protected]";
      var subject = "Update"+e.range.getSheet().getName();
      var body = "cell C13 has been updated";

        var datetime = Utilities.formatDate(new Date(), "IST", "yyyy/MM/dd HH: mm:ss");
      sheetName.getRange('H13').setValue(datetime); 

  //Send the Email
      MailApp.sendEmail(recipients, subject, body);
    }
  }
2
  • This seems like a question for Stack Overflow rather than this site.
    – freginold
    Commented Feb 18, 2018 at 3:37
  • 1
    It's okay here, I think, but it's tough to decipher what's being asked. Writing out the actual code you are trying would probably help.
    – jonsca
    Commented Feb 18, 2018 at 8:54

1 Answer 1

2

onEdit(e) and onChange Triggers(Both simple and Installable) will not trigger unless a human explicitly edits the file. In your case, Your seem to be getting value from an external source (specifically, finance data).

Script executions and API requests do not cause triggers to run. For example, calling FormResponse.submit() to submit a new form response does not cause the form's submit trigger to run.

Script executions and API requests do not cause triggers to run. For example, calling Range.setValue() to edit a cell does not cause the spreadsheet's onEdit trigger to run.

For update in spreadsheet itself,Please refer here to use a script.

1
  • I am using below query but i am not getting alert. Commented Feb 22, 2018 at 6:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.