Need Help with TimeStamp creation (doesn't work for new rows)

77 views
Skip to first unread message

Valentina Nitti

unread,
Oct 30, 2022, 11:04:59 AM10/30/22
to Google Apps Script Community
Hey community! I really need some help with creating a Script to insert a Timestamp every time a value in cell is changed (from a Data Validation Menu). 

I thought I made one script that worked, but by inserting new rows something is off and the script is not working anymore... How do I fix that? 

Ideally, If i fix this script, I wanted to add another one applying to another column, with the same mechanics in mind (data validation changes > timestamp with date of edit made)

Here's the example of scripts that I created, and I also have a copy of the WS I'd like to apply those >

function onEdit(e) {

var row = e.range.getRow ();
var sheet = e.source.getActiveSheet().getSheetName();
var tempSent = e.source.getSheetByName ("Disputed CR Forms").getRange (row,4).getValue();
var startDate = new Date();

if(row > 2 && sheet == "Disputed CR Forms" && tempSent !== ""){
e.source.getSheetByName ("Disputed CR Forms").getRange(row, 5).setValue(startDate);
}

Thanks for the help!!! 

Keith Andersen

unread,
Oct 30, 2022, 3:07:37 PM10/30/22
to google-apps-sc...@googlegroups.com
Here is a video that addresses this. There is a link in the description of the video to a spreadsheet you can copy and use as your own. You can then copy the app script or amend it to your needs.

https://youtu.be/EWagkthsleU

Hope it helps.

Keith

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/58f91250-14f1-4dea-90d3-cb5a2015bf88n%40googlegroups.com.

cbmserv...@gmail.com

unread,
Oct 30, 2022, 3:13:17 PM10/30/22
to google-apps-sc...@googlegroups.com

Hi Valentina,

 

The script is fine. Your issue is that you have 2 onEdit functions in that spreadsheet. One in StartingDateDispute and one in ResponseDate.

 

Google will only run one of the 2. It usually takes the last one defined. So your function below is not being run.

 

Delete the second one and you should be fine.

 

To apply the same to another range, just add that functionality in the same onEdit function.

 

After your first if statement, add a second if statement for your second range.

--

Reply all
Reply to author
Forward
0 new messages