Ticking checkbox triggers function to add time stampFinding all checkboxes in a Google SheetonEdit timestamp based on other sheetRecent Timezone changes in spreadsheet?onChange not firing when Spreadsheet edited by IFTTTChecking if cell note existChanging date range for chart based on selected dropdown valueChange onEdit Google Script to Time Based TriggerCalling an onEdit function inside of an onEdit installable trigger. Will it error for users who cannot edit a different tab on the spreadsheet?Google Sheets: Cannot edit Google Form responses even when using an onFormSubmit triggerOn edit trigger that inserts timestamp dependant on checkbox value
Read file lines into shell line separated by space
Who was the most successful German spy against Great Britain in WWII, from the contemporary German perspective?
How can I reorder triggered abilities in Arena?
What does "rel" in `mathrel` and `stackrel` stands for?
Why do banks “park” their money at the European Central Bank?
Are there any elected officials in the U.S. who are not legislators, judges, or constitutional officers?
How to find out the average duration of the peer-review process for a given journal?
What is the loud noise of a helicopter when the rotors are not yet moving?
How many lines of code does the original TeX contain?
“T” in subscript in formulas
How can I unambiguously ask for a new user's "Display Name"?
Evaluated vs. unevaluated Association
How do I get toddlers to stop asking for food every hour?
Cooking Scrambled Eggs
Where does learning new skills fit into Agile?
How to change image size without scaling in GIMP
If someone uses the Command spell and says "drop", what happens?
Nothing like a good ol' game of ModTen
Redacting URLs as an email-phishing preventative?
Is there any way to keep a player from killing an NPC?
What is the coil voltage of this contactor?
Where can/should I, as a high schooler, publish a paper regarding the derivation of a formula?
Architectural feasibility of a tiered circular stone keep
Does ostensible/specious make sense in this sentence?
Ticking checkbox triggers function to add time stamp
Finding all checkboxes in a Google SheetonEdit timestamp based on other sheetRecent Timezone changes in spreadsheet?onChange not firing when Spreadsheet edited by IFTTTChecking if cell note existChanging date range for chart based on selected dropdown valueChange onEdit Google Script to Time Based TriggerCalling an onEdit function inside of an onEdit installable trigger. Will it error for users who cannot edit a different tab on the spreadsheet?Google Sheets: Cannot edit Google Form responses even when using an onFormSubmit triggerOn edit trigger that inserts timestamp dependant on checkbox value
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm building a spreadsheet that tracks specific data. I want to place a timestamp in the corresponding adjacent cell when I tick a checkbox - alternative I would be happy with a note on the checkbox stating the time it was last ticked TRUE.
I have literally spent an entire day searching everything on Stackoverflow and google, and I have tried many different methods and functions. Primarily I have been using the onEdit(e) function to (try and) add the time stamp. Early attempts identified a known flaw that meant onEdit(e) wasn't capturing all instances of the checkbox change state. I changed my approach accordingly, both attempting to add the timestamp to the corresponding adjacent cell, and also add a note to the checkbox cell - both seemed to work sporadically which was extremely frustrating.
I have three primary issues with this problem at the moment:
Knowing the syntax for checking the value of the checkbox (do I use ==, or ===, and do I use
'',", or no quotation marks?). That sounds like a very stupid question, but I have learning difficulties and have significant trouble retaining written information in my memory :(Successfully setting an `if' -> 'else if' statement that will "toggle" the timestamp on or off depending on the state of the checkbox.
I would prefer to set a note with the timestamp on the checkbox cell that is cleared when the checkbox is unticked - however the few times I did get it to work the timezone was incorrect. I did a lot of reading about
timezonebut without a working example I was unable to comprehend how to implement it into my code. I'm +10 GMT
I have provided a cut down version of my spreadsheet containing only the specific sheet & code I am having trouble with:
https://docs.google.com/spreadsheets/d/1NCdMziBpj0joSv9lQfqT9etz9hMsvgMeuT8X9XTxR20/edit?usp=sharing
Here is the latest iteration of code I have been working on. I've probably attempted half a dozen completely different functions but have deleted each one after several hours of hitting brick walls:
function onEdit()
var ss = SpreadsheetApp.getActiveSheet();
if(ss.getName() == "Quests" ) //checks that we're on the correct sheet
var tickboxCell = s.getActiveCell();
if(tickboxCell.getColumn() == 3 && tickboxCell.getValue() === 'TRUE' ) //checks the status of the tickbox
var dateCell = tickboxCell.offset(0, 1);
dateCell.setValue(new Date());
Here is the sample code I modified for adding a note to the checkbox:
function setNote(note)
var note = note;
var cell = SpreadsheetApp.getActiveSheet().getActiveCell();
if(note == "")
cell.clearNote();
else
cell.setNote(note);
I would expect that any time a checkbox is ticked, either the corresponding cell to the right would input date(), or alternatively the checkbox would add a note stating "Quest Completed: dd/mm/yyy" (+10 GMT timezone). I would then expect the timestamp cell to clear, or the note to be cleared if the checkbox state is unticked.
google-apps-script google-sheets
add a comment |
I'm building a spreadsheet that tracks specific data. I want to place a timestamp in the corresponding adjacent cell when I tick a checkbox - alternative I would be happy with a note on the checkbox stating the time it was last ticked TRUE.
I have literally spent an entire day searching everything on Stackoverflow and google, and I have tried many different methods and functions. Primarily I have been using the onEdit(e) function to (try and) add the time stamp. Early attempts identified a known flaw that meant onEdit(e) wasn't capturing all instances of the checkbox change state. I changed my approach accordingly, both attempting to add the timestamp to the corresponding adjacent cell, and also add a note to the checkbox cell - both seemed to work sporadically which was extremely frustrating.
I have three primary issues with this problem at the moment:
Knowing the syntax for checking the value of the checkbox (do I use ==, or ===, and do I use
'',", or no quotation marks?). That sounds like a very stupid question, but I have learning difficulties and have significant trouble retaining written information in my memory :(Successfully setting an `if' -> 'else if' statement that will "toggle" the timestamp on or off depending on the state of the checkbox.
I would prefer to set a note with the timestamp on the checkbox cell that is cleared when the checkbox is unticked - however the few times I did get it to work the timezone was incorrect. I did a lot of reading about
timezonebut without a working example I was unable to comprehend how to implement it into my code. I'm +10 GMT
I have provided a cut down version of my spreadsheet containing only the specific sheet & code I am having trouble with:
https://docs.google.com/spreadsheets/d/1NCdMziBpj0joSv9lQfqT9etz9hMsvgMeuT8X9XTxR20/edit?usp=sharing
Here is the latest iteration of code I have been working on. I've probably attempted half a dozen completely different functions but have deleted each one after several hours of hitting brick walls:
function onEdit()
var ss = SpreadsheetApp.getActiveSheet();
if(ss.getName() == "Quests" ) //checks that we're on the correct sheet
var tickboxCell = s.getActiveCell();
if(tickboxCell.getColumn() == 3 && tickboxCell.getValue() === 'TRUE' ) //checks the status of the tickbox
var dateCell = tickboxCell.offset(0, 1);
dateCell.setValue(new Date());
Here is the sample code I modified for adding a note to the checkbox:
function setNote(note)
var note = note;
var cell = SpreadsheetApp.getActiveSheet().getActiveCell();
if(note == "")
cell.clearNote();
else
cell.setNote(note);
I would expect that any time a checkbox is ticked, either the corresponding cell to the right would input date(), or alternatively the checkbox would add a note stating "Quest Completed: dd/mm/yyy" (+10 GMT timezone). I would then expect the timestamp cell to clear, or the note to be cleared if the checkbox state is unticked.
google-apps-script google-sheets
2
Checkboxes can have any value signify "checked" state, and any other value signify "unchecked". You can create checkboxes where "FALSE" means "checked" and "TRUE" means "unchecked". You need to compare the cell value to the data validation rule's criteria, see my q & a here. As far as==vs===, prefer strict equality in almost every case you can conceive of.
– tehhowch
Mar 27 at 19:30
1
stackoverflow.com/help/someone-answers (you should avoid placing the solution in your answer)
– tehhowch
Mar 27 at 20:41
Well you tell me how to format code in the comments so it's not a jumbled mess. When I'm happy with a final answer I'll post it accordingly. What else do you want to tell me I'm doing wrong?
– Aaron Irvine
Mar 27 at 21:24
2
If Cooper's post answered your single, specific question, then mark it as the answer. (One question = one post.) If you have a second or a follow-up question, ask a new one, and give it the same workup you did here, where you explain the issue and what you've done to try to solve it, and what related SO / internet posts you found when researching it. Comments aren't for posting complicated code.
– tehhowch
Mar 27 at 22:05
add a comment |
I'm building a spreadsheet that tracks specific data. I want to place a timestamp in the corresponding adjacent cell when I tick a checkbox - alternative I would be happy with a note on the checkbox stating the time it was last ticked TRUE.
I have literally spent an entire day searching everything on Stackoverflow and google, and I have tried many different methods and functions. Primarily I have been using the onEdit(e) function to (try and) add the time stamp. Early attempts identified a known flaw that meant onEdit(e) wasn't capturing all instances of the checkbox change state. I changed my approach accordingly, both attempting to add the timestamp to the corresponding adjacent cell, and also add a note to the checkbox cell - both seemed to work sporadically which was extremely frustrating.
I have three primary issues with this problem at the moment:
Knowing the syntax for checking the value of the checkbox (do I use ==, or ===, and do I use
'',", or no quotation marks?). That sounds like a very stupid question, but I have learning difficulties and have significant trouble retaining written information in my memory :(Successfully setting an `if' -> 'else if' statement that will "toggle" the timestamp on or off depending on the state of the checkbox.
I would prefer to set a note with the timestamp on the checkbox cell that is cleared when the checkbox is unticked - however the few times I did get it to work the timezone was incorrect. I did a lot of reading about
timezonebut without a working example I was unable to comprehend how to implement it into my code. I'm +10 GMT
I have provided a cut down version of my spreadsheet containing only the specific sheet & code I am having trouble with:
https://docs.google.com/spreadsheets/d/1NCdMziBpj0joSv9lQfqT9etz9hMsvgMeuT8X9XTxR20/edit?usp=sharing
Here is the latest iteration of code I have been working on. I've probably attempted half a dozen completely different functions but have deleted each one after several hours of hitting brick walls:
function onEdit()
var ss = SpreadsheetApp.getActiveSheet();
if(ss.getName() == "Quests" ) //checks that we're on the correct sheet
var tickboxCell = s.getActiveCell();
if(tickboxCell.getColumn() == 3 && tickboxCell.getValue() === 'TRUE' ) //checks the status of the tickbox
var dateCell = tickboxCell.offset(0, 1);
dateCell.setValue(new Date());
Here is the sample code I modified for adding a note to the checkbox:
function setNote(note)
var note = note;
var cell = SpreadsheetApp.getActiveSheet().getActiveCell();
if(note == "")
cell.clearNote();
else
cell.setNote(note);
I would expect that any time a checkbox is ticked, either the corresponding cell to the right would input date(), or alternatively the checkbox would add a note stating "Quest Completed: dd/mm/yyy" (+10 GMT timezone). I would then expect the timestamp cell to clear, or the note to be cleared if the checkbox state is unticked.
google-apps-script google-sheets
I'm building a spreadsheet that tracks specific data. I want to place a timestamp in the corresponding adjacent cell when I tick a checkbox - alternative I would be happy with a note on the checkbox stating the time it was last ticked TRUE.
I have literally spent an entire day searching everything on Stackoverflow and google, and I have tried many different methods and functions. Primarily I have been using the onEdit(e) function to (try and) add the time stamp. Early attempts identified a known flaw that meant onEdit(e) wasn't capturing all instances of the checkbox change state. I changed my approach accordingly, both attempting to add the timestamp to the corresponding adjacent cell, and also add a note to the checkbox cell - both seemed to work sporadically which was extremely frustrating.
I have three primary issues with this problem at the moment:
Knowing the syntax for checking the value of the checkbox (do I use ==, or ===, and do I use
'',", or no quotation marks?). That sounds like a very stupid question, but I have learning difficulties and have significant trouble retaining written information in my memory :(Successfully setting an `if' -> 'else if' statement that will "toggle" the timestamp on or off depending on the state of the checkbox.
I would prefer to set a note with the timestamp on the checkbox cell that is cleared when the checkbox is unticked - however the few times I did get it to work the timezone was incorrect. I did a lot of reading about
timezonebut without a working example I was unable to comprehend how to implement it into my code. I'm +10 GMT
I have provided a cut down version of my spreadsheet containing only the specific sheet & code I am having trouble with:
https://docs.google.com/spreadsheets/d/1NCdMziBpj0joSv9lQfqT9etz9hMsvgMeuT8X9XTxR20/edit?usp=sharing
Here is the latest iteration of code I have been working on. I've probably attempted half a dozen completely different functions but have deleted each one after several hours of hitting brick walls:
function onEdit()
var ss = SpreadsheetApp.getActiveSheet();
if(ss.getName() == "Quests" ) //checks that we're on the correct sheet
var tickboxCell = s.getActiveCell();
if(tickboxCell.getColumn() == 3 && tickboxCell.getValue() === 'TRUE' ) //checks the status of the tickbox
var dateCell = tickboxCell.offset(0, 1);
dateCell.setValue(new Date());
Here is the sample code I modified for adding a note to the checkbox:
function setNote(note)
var note = note;
var cell = SpreadsheetApp.getActiveSheet().getActiveCell();
if(note == "")
cell.clearNote();
else
cell.setNote(note);
I would expect that any time a checkbox is ticked, either the corresponding cell to the right would input date(), or alternatively the checkbox would add a note stating "Quest Completed: dd/mm/yyy" (+10 GMT timezone). I would then expect the timestamp cell to clear, or the note to be cleared if the checkbox state is unticked.
google-apps-script google-sheets
google-apps-script google-sheets
edited Mar 28 at 7:26
Aaron Irvine
asked Mar 27 at 18:53
Aaron IrvineAaron Irvine
627 bronze badges
627 bronze badges
2
Checkboxes can have any value signify "checked" state, and any other value signify "unchecked". You can create checkboxes where "FALSE" means "checked" and "TRUE" means "unchecked". You need to compare the cell value to the data validation rule's criteria, see my q & a here. As far as==vs===, prefer strict equality in almost every case you can conceive of.
– tehhowch
Mar 27 at 19:30
1
stackoverflow.com/help/someone-answers (you should avoid placing the solution in your answer)
– tehhowch
Mar 27 at 20:41
Well you tell me how to format code in the comments so it's not a jumbled mess. When I'm happy with a final answer I'll post it accordingly. What else do you want to tell me I'm doing wrong?
– Aaron Irvine
Mar 27 at 21:24
2
If Cooper's post answered your single, specific question, then mark it as the answer. (One question = one post.) If you have a second or a follow-up question, ask a new one, and give it the same workup you did here, where you explain the issue and what you've done to try to solve it, and what related SO / internet posts you found when researching it. Comments aren't for posting complicated code.
– tehhowch
Mar 27 at 22:05
add a comment |
2
Checkboxes can have any value signify "checked" state, and any other value signify "unchecked". You can create checkboxes where "FALSE" means "checked" and "TRUE" means "unchecked". You need to compare the cell value to the data validation rule's criteria, see my q & a here. As far as==vs===, prefer strict equality in almost every case you can conceive of.
– tehhowch
Mar 27 at 19:30
1
stackoverflow.com/help/someone-answers (you should avoid placing the solution in your answer)
– tehhowch
Mar 27 at 20:41
Well you tell me how to format code in the comments so it's not a jumbled mess. When I'm happy with a final answer I'll post it accordingly. What else do you want to tell me I'm doing wrong?
– Aaron Irvine
Mar 27 at 21:24
2
If Cooper's post answered your single, specific question, then mark it as the answer. (One question = one post.) If you have a second or a follow-up question, ask a new one, and give it the same workup you did here, where you explain the issue and what you've done to try to solve it, and what related SO / internet posts you found when researching it. Comments aren't for posting complicated code.
– tehhowch
Mar 27 at 22:05
2
2
Checkboxes can have any value signify "checked" state, and any other value signify "unchecked". You can create checkboxes where "FALSE" means "checked" and "TRUE" means "unchecked". You need to compare the cell value to the data validation rule's criteria, see my q & a here. As far as
== vs ===, prefer strict equality in almost every case you can conceive of.– tehhowch
Mar 27 at 19:30
Checkboxes can have any value signify "checked" state, and any other value signify "unchecked". You can create checkboxes where "FALSE" means "checked" and "TRUE" means "unchecked". You need to compare the cell value to the data validation rule's criteria, see my q & a here. As far as
== vs ===, prefer strict equality in almost every case you can conceive of.– tehhowch
Mar 27 at 19:30
1
1
stackoverflow.com/help/someone-answers (you should avoid placing the solution in your answer)
– tehhowch
Mar 27 at 20:41
stackoverflow.com/help/someone-answers (you should avoid placing the solution in your answer)
– tehhowch
Mar 27 at 20:41
Well you tell me how to format code in the comments so it's not a jumbled mess. When I'm happy with a final answer I'll post it accordingly. What else do you want to tell me I'm doing wrong?
– Aaron Irvine
Mar 27 at 21:24
Well you tell me how to format code in the comments so it's not a jumbled mess. When I'm happy with a final answer I'll post it accordingly. What else do you want to tell me I'm doing wrong?
– Aaron Irvine
Mar 27 at 21:24
2
2
If Cooper's post answered your single, specific question, then mark it as the answer. (One question = one post.) If you have a second or a follow-up question, ask a new one, and give it the same workup you did here, where you explain the issue and what you've done to try to solve it, and what related SO / internet posts you found when researching it. Comments aren't for posting complicated code.
– tehhowch
Mar 27 at 22:05
If Cooper's post answered your single, specific question, then mark it as the answer. (One question = one post.) If you have a second or a follow-up question, ask a new one, and give it the same workup you did here, where you explain the issue and what you've done to try to solve it, and what related SO / internet posts you found when researching it. Comments aren't for posting complicated code.
– tehhowch
Mar 27 at 22:05
add a comment |
2 Answers
2
active
oldest
votes
try this:
function onEdit(e)
if(e.range.getSheet().getName() != 'Quests') return;
if(e.range.columnStart==3 && e.value=="TRUE")
e.range.offset(0,1).setValue(Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "yyyyMMdd:HHmm"));
Advise me please Cooper - should I accept your answer as without it I wouldn't have gotten to my final solution? Or should I accept mine as it's the final script that does everything I was asking in the question. I'm greatly appreciative of your help.
– Aaron Irvine
Mar 28 at 7:27
1
The goal of this site is programmers helping each other become better better programmers not who has the most points. Personally, I take great pride in being able to modify my own programs to my own needs and I’m glad that you were able to take the initiative to improve upon my work and get an answer that you desired so choose your own answer and be happy about it.
– Cooper
Mar 28 at 13:13
Thank you Cooper, you're very kind. Can I come straight to you and avoid all this judgey cliche crowd in future? j/k :D
– Aaron Irvine
Mar 28 at 13:32
1
The best way to utilize stack overflow in my opinion is to create a minimal complete verifiable example that contains the essence of what your question is. That’s what I do in my own work. When I start to run into a problem that looks like something that I’ve never seen before I start to try to think about how I can write this minimal complete verifiable example so that I can submit it as a question to stack overflow. Very often it helps me to solve my own problem. When it doesn’t it becomes a question.
– Cooper
Mar 28 at 17:03
Trying to avoid other volunteers will only hurt you because many of them know a lot more than I do.
– Cooper
Mar 28 at 17:04
|
show 1 more comment
Thanks to Cooper who put me on the right path with his code. It didn't do exactly what I was looking for, but it enabled me to make a few minor changes to it to get exactly what I was looking for.
EDIT: I have found the solution for setNote as well which I will provide here.
Code for adding/removing date to adjacent cell:
function onEdit(e)
if (e.range.getSheet().getName() != 'Quests') return;
if (e.range.columnStart==3 && e.value=="TRUE")
e.range.offset(0,1).setValue(new Date());
else if (e.range.columnStart==3 && e.value=="FALSE")
e.range.offset(0,1).clearContent();
Code for adding/removing setNote from tickbox with correct timezone:
if(e.range.getSheet().getName() != 'Quests') return;
if(e.range.columnStart==3 && e.value=="TRUE")
e.range.setNote('Completed: ' + Utilities.formatDate(new Date(), SpreadsheetApp.getActive().getSpreadsheetTimeZone(), "dd-MM-yy HH:mm:ss"));
else if (e.range.columnStart==3 && e.value=="FALSE")
e.range.clearNote();
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55384574%2fticking-checkbox-triggers-function-to-add-time-stamp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
try this:
function onEdit(e)
if(e.range.getSheet().getName() != 'Quests') return;
if(e.range.columnStart==3 && e.value=="TRUE")
e.range.offset(0,1).setValue(Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "yyyyMMdd:HHmm"));
Advise me please Cooper - should I accept your answer as without it I wouldn't have gotten to my final solution? Or should I accept mine as it's the final script that does everything I was asking in the question. I'm greatly appreciative of your help.
– Aaron Irvine
Mar 28 at 7:27
1
The goal of this site is programmers helping each other become better better programmers not who has the most points. Personally, I take great pride in being able to modify my own programs to my own needs and I’m glad that you were able to take the initiative to improve upon my work and get an answer that you desired so choose your own answer and be happy about it.
– Cooper
Mar 28 at 13:13
Thank you Cooper, you're very kind. Can I come straight to you and avoid all this judgey cliche crowd in future? j/k :D
– Aaron Irvine
Mar 28 at 13:32
1
The best way to utilize stack overflow in my opinion is to create a minimal complete verifiable example that contains the essence of what your question is. That’s what I do in my own work. When I start to run into a problem that looks like something that I’ve never seen before I start to try to think about how I can write this minimal complete verifiable example so that I can submit it as a question to stack overflow. Very often it helps me to solve my own problem. When it doesn’t it becomes a question.
– Cooper
Mar 28 at 17:03
Trying to avoid other volunteers will only hurt you because many of them know a lot more than I do.
– Cooper
Mar 28 at 17:04
|
show 1 more comment
try this:
function onEdit(e)
if(e.range.getSheet().getName() != 'Quests') return;
if(e.range.columnStart==3 && e.value=="TRUE")
e.range.offset(0,1).setValue(Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "yyyyMMdd:HHmm"));
Advise me please Cooper - should I accept your answer as without it I wouldn't have gotten to my final solution? Or should I accept mine as it's the final script that does everything I was asking in the question. I'm greatly appreciative of your help.
– Aaron Irvine
Mar 28 at 7:27
1
The goal of this site is programmers helping each other become better better programmers not who has the most points. Personally, I take great pride in being able to modify my own programs to my own needs and I’m glad that you were able to take the initiative to improve upon my work and get an answer that you desired so choose your own answer and be happy about it.
– Cooper
Mar 28 at 13:13
Thank you Cooper, you're very kind. Can I come straight to you and avoid all this judgey cliche crowd in future? j/k :D
– Aaron Irvine
Mar 28 at 13:32
1
The best way to utilize stack overflow in my opinion is to create a minimal complete verifiable example that contains the essence of what your question is. That’s what I do in my own work. When I start to run into a problem that looks like something that I’ve never seen before I start to try to think about how I can write this minimal complete verifiable example so that I can submit it as a question to stack overflow. Very often it helps me to solve my own problem. When it doesn’t it becomes a question.
– Cooper
Mar 28 at 17:03
Trying to avoid other volunteers will only hurt you because many of them know a lot more than I do.
– Cooper
Mar 28 at 17:04
|
show 1 more comment
try this:
function onEdit(e)
if(e.range.getSheet().getName() != 'Quests') return;
if(e.range.columnStart==3 && e.value=="TRUE")
e.range.offset(0,1).setValue(Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "yyyyMMdd:HHmm"));
try this:
function onEdit(e)
if(e.range.getSheet().getName() != 'Quests') return;
if(e.range.columnStart==3 && e.value=="TRUE")
e.range.offset(0,1).setValue(Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "yyyyMMdd:HHmm"));
edited Mar 27 at 19:28
answered Mar 27 at 19:04
CooperCooper
12.3k3 gold badges9 silver badges33 bronze badges
12.3k3 gold badges9 silver badges33 bronze badges
Advise me please Cooper - should I accept your answer as without it I wouldn't have gotten to my final solution? Or should I accept mine as it's the final script that does everything I was asking in the question. I'm greatly appreciative of your help.
– Aaron Irvine
Mar 28 at 7:27
1
The goal of this site is programmers helping each other become better better programmers not who has the most points. Personally, I take great pride in being able to modify my own programs to my own needs and I’m glad that you were able to take the initiative to improve upon my work and get an answer that you desired so choose your own answer and be happy about it.
– Cooper
Mar 28 at 13:13
Thank you Cooper, you're very kind. Can I come straight to you and avoid all this judgey cliche crowd in future? j/k :D
– Aaron Irvine
Mar 28 at 13:32
1
The best way to utilize stack overflow in my opinion is to create a minimal complete verifiable example that contains the essence of what your question is. That’s what I do in my own work. When I start to run into a problem that looks like something that I’ve never seen before I start to try to think about how I can write this minimal complete verifiable example so that I can submit it as a question to stack overflow. Very often it helps me to solve my own problem. When it doesn’t it becomes a question.
– Cooper
Mar 28 at 17:03
Trying to avoid other volunteers will only hurt you because many of them know a lot more than I do.
– Cooper
Mar 28 at 17:04
|
show 1 more comment
Advise me please Cooper - should I accept your answer as without it I wouldn't have gotten to my final solution? Or should I accept mine as it's the final script that does everything I was asking in the question. I'm greatly appreciative of your help.
– Aaron Irvine
Mar 28 at 7:27
1
The goal of this site is programmers helping each other become better better programmers not who has the most points. Personally, I take great pride in being able to modify my own programs to my own needs and I’m glad that you were able to take the initiative to improve upon my work and get an answer that you desired so choose your own answer and be happy about it.
– Cooper
Mar 28 at 13:13
Thank you Cooper, you're very kind. Can I come straight to you and avoid all this judgey cliche crowd in future? j/k :D
– Aaron Irvine
Mar 28 at 13:32
1
The best way to utilize stack overflow in my opinion is to create a minimal complete verifiable example that contains the essence of what your question is. That’s what I do in my own work. When I start to run into a problem that looks like something that I’ve never seen before I start to try to think about how I can write this minimal complete verifiable example so that I can submit it as a question to stack overflow. Very often it helps me to solve my own problem. When it doesn’t it becomes a question.
– Cooper
Mar 28 at 17:03
Trying to avoid other volunteers will only hurt you because many of them know a lot more than I do.
– Cooper
Mar 28 at 17:04
Advise me please Cooper - should I accept your answer as without it I wouldn't have gotten to my final solution? Or should I accept mine as it's the final script that does everything I was asking in the question. I'm greatly appreciative of your help.
– Aaron Irvine
Mar 28 at 7:27
Advise me please Cooper - should I accept your answer as without it I wouldn't have gotten to my final solution? Or should I accept mine as it's the final script that does everything I was asking in the question. I'm greatly appreciative of your help.
– Aaron Irvine
Mar 28 at 7:27
1
1
The goal of this site is programmers helping each other become better better programmers not who has the most points. Personally, I take great pride in being able to modify my own programs to my own needs and I’m glad that you were able to take the initiative to improve upon my work and get an answer that you desired so choose your own answer and be happy about it.
– Cooper
Mar 28 at 13:13
The goal of this site is programmers helping each other become better better programmers not who has the most points. Personally, I take great pride in being able to modify my own programs to my own needs and I’m glad that you were able to take the initiative to improve upon my work and get an answer that you desired so choose your own answer and be happy about it.
– Cooper
Mar 28 at 13:13
Thank you Cooper, you're very kind. Can I come straight to you and avoid all this judgey cliche crowd in future? j/k :D
– Aaron Irvine
Mar 28 at 13:32
Thank you Cooper, you're very kind. Can I come straight to you and avoid all this judgey cliche crowd in future? j/k :D
– Aaron Irvine
Mar 28 at 13:32
1
1
The best way to utilize stack overflow in my opinion is to create a minimal complete verifiable example that contains the essence of what your question is. That’s what I do in my own work. When I start to run into a problem that looks like something that I’ve never seen before I start to try to think about how I can write this minimal complete verifiable example so that I can submit it as a question to stack overflow. Very often it helps me to solve my own problem. When it doesn’t it becomes a question.
– Cooper
Mar 28 at 17:03
The best way to utilize stack overflow in my opinion is to create a minimal complete verifiable example that contains the essence of what your question is. That’s what I do in my own work. When I start to run into a problem that looks like something that I’ve never seen before I start to try to think about how I can write this minimal complete verifiable example so that I can submit it as a question to stack overflow. Very often it helps me to solve my own problem. When it doesn’t it becomes a question.
– Cooper
Mar 28 at 17:03
Trying to avoid other volunteers will only hurt you because many of them know a lot more than I do.
– Cooper
Mar 28 at 17:04
Trying to avoid other volunteers will only hurt you because many of them know a lot more than I do.
– Cooper
Mar 28 at 17:04
|
show 1 more comment
Thanks to Cooper who put me on the right path with his code. It didn't do exactly what I was looking for, but it enabled me to make a few minor changes to it to get exactly what I was looking for.
EDIT: I have found the solution for setNote as well which I will provide here.
Code for adding/removing date to adjacent cell:
function onEdit(e)
if (e.range.getSheet().getName() != 'Quests') return;
if (e.range.columnStart==3 && e.value=="TRUE")
e.range.offset(0,1).setValue(new Date());
else if (e.range.columnStart==3 && e.value=="FALSE")
e.range.offset(0,1).clearContent();
Code for adding/removing setNote from tickbox with correct timezone:
if(e.range.getSheet().getName() != 'Quests') return;
if(e.range.columnStart==3 && e.value=="TRUE")
e.range.setNote('Completed: ' + Utilities.formatDate(new Date(), SpreadsheetApp.getActive().getSpreadsheetTimeZone(), "dd-MM-yy HH:mm:ss"));
else if (e.range.columnStart==3 && e.value=="FALSE")
e.range.clearNote();
add a comment |
Thanks to Cooper who put me on the right path with his code. It didn't do exactly what I was looking for, but it enabled me to make a few minor changes to it to get exactly what I was looking for.
EDIT: I have found the solution for setNote as well which I will provide here.
Code for adding/removing date to adjacent cell:
function onEdit(e)
if (e.range.getSheet().getName() != 'Quests') return;
if (e.range.columnStart==3 && e.value=="TRUE")
e.range.offset(0,1).setValue(new Date());
else if (e.range.columnStart==3 && e.value=="FALSE")
e.range.offset(0,1).clearContent();
Code for adding/removing setNote from tickbox with correct timezone:
if(e.range.getSheet().getName() != 'Quests') return;
if(e.range.columnStart==3 && e.value=="TRUE")
e.range.setNote('Completed: ' + Utilities.formatDate(new Date(), SpreadsheetApp.getActive().getSpreadsheetTimeZone(), "dd-MM-yy HH:mm:ss"));
else if (e.range.columnStart==3 && e.value=="FALSE")
e.range.clearNote();
add a comment |
Thanks to Cooper who put me on the right path with his code. It didn't do exactly what I was looking for, but it enabled me to make a few minor changes to it to get exactly what I was looking for.
EDIT: I have found the solution for setNote as well which I will provide here.
Code for adding/removing date to adjacent cell:
function onEdit(e)
if (e.range.getSheet().getName() != 'Quests') return;
if (e.range.columnStart==3 && e.value=="TRUE")
e.range.offset(0,1).setValue(new Date());
else if (e.range.columnStart==3 && e.value=="FALSE")
e.range.offset(0,1).clearContent();
Code for adding/removing setNote from tickbox with correct timezone:
if(e.range.getSheet().getName() != 'Quests') return;
if(e.range.columnStart==3 && e.value=="TRUE")
e.range.setNote('Completed: ' + Utilities.formatDate(new Date(), SpreadsheetApp.getActive().getSpreadsheetTimeZone(), "dd-MM-yy HH:mm:ss"));
else if (e.range.columnStart==3 && e.value=="FALSE")
e.range.clearNote();
Thanks to Cooper who put me on the right path with his code. It didn't do exactly what I was looking for, but it enabled me to make a few minor changes to it to get exactly what I was looking for.
EDIT: I have found the solution for setNote as well which I will provide here.
Code for adding/removing date to adjacent cell:
function onEdit(e)
if (e.range.getSheet().getName() != 'Quests') return;
if (e.range.columnStart==3 && e.value=="TRUE")
e.range.offset(0,1).setValue(new Date());
else if (e.range.columnStart==3 && e.value=="FALSE")
e.range.offset(0,1).clearContent();
Code for adding/removing setNote from tickbox with correct timezone:
if(e.range.getSheet().getName() != 'Quests') return;
if(e.range.columnStart==3 && e.value=="TRUE")
e.range.setNote('Completed: ' + Utilities.formatDate(new Date(), SpreadsheetApp.getActive().getSpreadsheetTimeZone(), "dd-MM-yy HH:mm:ss"));
else if (e.range.columnStart==3 && e.value=="FALSE")
e.range.clearNote();
edited Mar 30 at 8:34
answered Mar 28 at 7:03
Aaron IrvineAaron Irvine
627 bronze badges
627 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55384574%2fticking-checkbox-triggers-function-to-add-time-stamp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Checkboxes can have any value signify "checked" state, and any other value signify "unchecked". You can create checkboxes where "FALSE" means "checked" and "TRUE" means "unchecked". You need to compare the cell value to the data validation rule's criteria, see my q & a here. As far as
==vs===, prefer strict equality in almost every case you can conceive of.– tehhowch
Mar 27 at 19:30
1
stackoverflow.com/help/someone-answers (you should avoid placing the solution in your answer)
– tehhowch
Mar 27 at 20:41
Well you tell me how to format code in the comments so it's not a jumbled mess. When I'm happy with a final answer I'll post it accordingly. What else do you want to tell me I'm doing wrong?
– Aaron Irvine
Mar 27 at 21:24
2
If Cooper's post answered your single, specific question, then mark it as the answer. (One question = one post.) If you have a second or a follow-up question, ask a new one, and give it the same workup you did here, where you explain the issue and what you've done to try to solve it, and what related SO / internet posts you found when researching it. Comments aren't for posting complicated code.
– tehhowch
Mar 27 at 22:05