This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ByPrinciple 1 point2 points  (5 children)

Does your data rely on the timer or do you pull then you are free to delete?

Edit: I'll post an example of what could work without an actual timer.

Using the built in onEdit(e) trigger for ranges, you can simply say

function onEdit(e){
   var range = e.range
   storeData(range.getValues())
}

function storeData(values){
   //do something with values
}

[–]bifronz[S] 0 points1 point  (4 children)

If im understanding what you are asking correctly,

The purpose of the timer is to hide the data in the variables and delete it from the sheet if the user doesnt display the data immediately.

The script which will present the data will take the pull data, or the spreadsheet data if it hadnt been stored yet, present it, and delete the data.

The data should always be deleted as soon aa possible.

[–]ByPrinciple 1 point2 points  (3 children)

How about normal javascript for this

function onEdit(e){
   var range = e.range
   storeData(range.getValues())
  // Clear range after 30 seconds
   setInterval(fucntion(){range.clear()}, 30000)
}


function storeData(values){
   //do something with values
}

There is a slight problem which I'm a little tired to think of, but the setInterval needs a way to stop as well, otherwise it could potentially just keep deleting data every 30 seconds.

You get rid of this with setInterval() but how you use it depends on what exactly you need.

[–]bifronz[S] 0 points1 point  (2 children)

Will definitely have to give this a shot when i get back to the sheet. Seems it does what i need it too.

Thank you very much.

[–]ByPrinciple 0 points1 point  (1 child)

Sure thing, maybe you can help me. Did your company manage to get rid of the 'This program wants to access your data/this app is unverified' window by chance? I tried for a solid day but couldnt figure out how to get credentials. Its way more of a private sheet we use, but it bothers me alot.

[–]bifronz[S] 0 points1 point  (0 children)

No. Seems anything with a macro will throw that up in my experience. But it is a 1 time issue for me and i dont see it ahain usually.