0
votes

I have a basic Google script to copy and paste google forms submissions from response sheet to another sheet for calcs ect ,to save keep copying the whole range of rows . I would like to store the last value of getlastRow() and store as a var prevRow.

Next time the script is run I can by subtracting the difference of old and new rows.I can then copy&paste only from the new data (response) I received .

So basically I need to know a BASIC METHOD to store a value and recall it next time the script is run. Kind regards

1
you can save old value in file in Google drive and recall it by reading next time. - Jignesh

1 Answers

0
votes

Basic method: Store the value in a cell. If the cell is hidden, styled or just off the screen then your user probably won't mess with it.

Better method: Use the PropertiesService. It stores values in your document and you can read them back later on. I use it for storing metadata about a document and have found it very effective.

To save a value:

var documentProperties = PropertiesService.getDocumentProperties();
documentProperties.setProperty("lastRow", lastRow);

To read it back:

var documentProperties = PropertiesService.getDocumentProperties();
var lastRow = documentProperties.getProperty("lastRow");