'adding timestamp when form is submitted , google app script

i want to generate a timestamp in google sheet cell only once the form submitted .

i generate form from sheetdb and then put the script into my wordpress website .

issue : the function which i created only works when i write something in cell manully , but when i fill the form and submit date get to my sheet but timestamp doesn't work .

my code :

function onEdit(e) {
  const row = e.range.getRow();
  const col = e.range.getColumn();

  if(col === 1 ){
    e.source.getActiveSheet().getRange(row,7).setValue(new Date());
  }
  
}

here my sheet with issue :

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source