I am looking for a script that will allow for a cell to be locked once data has been entered.
For instance I have a sign in sheet that has several columns.
ColumnA= Student Name, ColumnB= check box for checking in, ColumnC= check box for checking out, ColumnD= Time, ColumnE= Dropdown list for reasons.
My desire is that once data is entered the cells are locked so that once StudentA inserts their information then StudentB that access the google sheet at a later time can not purposefully or accidentally adjust StudentA's info.
Is this a possibility with a script, I know that I cannot do it with conditional formatting.
Thanks
It's cleanest to do it with a form. Do the students need to be able to see each others signins or their own in retrospect?
Related
the sheet I'm working on generates a request number on the very first submission a user makes of a google form based off of information the user inputted in the form and a timestamp. Now, because I need for the user to be able to edit their response later which causes the form to be re-submitted, I want the request number not to be regenerated, and to stay the same as when it was initially generated. Is there any way to prevent a cell from changing from its initial value when it contains a formula that references a cell that updates?
Here is the formula contained in the cell I don't want to update with alongside its references:
=ARRAYFORMULA(ARRAY_CONSTRAIN(if(ROW(A:A)=1, "Request ID", if(D1:D="", "",C1:C&"-"&G1:G&"-"&N1:N)), MAX(if(D1:D="",0,ROW(D1:D)))-ROW()+1,1))
The formula appends different values received from the form together to create a request number (formatted as essentially C1:C-G1:G-N1:N, timestamp-System-initials) and the arrayformula and constraint ensures the formula is copied to each row in the sheet that contains a form response so far. I want this request number to stay the same as it's initial value, even as columns C, G, and N change.
Edit: Not really sure how I can provide a search history on what I've tried so far because I've been searching for anything I can to fix this problem because it's important. I've looked into indirect referencing, absolute references, considered using PropertiesService (Google Apps Script) in order to store whether the request number has been initiated before and got stuck there, considered copying the value into another column to store it but again the autoupdating feature that accompanies linking cells of course still remains an issue. I'm stuck on what kind of function/workaround I could use to achieve this. Look forward to your thoughts. I've also tried a number of other strategies as well.
Since formulas recalculate each time the spreadsheet is recalculated using a formula is not the right way to keep the original value on the current spreadsheet version. The way to achieve this is by using a script to log those values.
There are already a lot of questions about using a script to log values from one sheet to another. Here are few examples
How to Get (& Set) cell values from one sheet to another in Google Sheets?
I want to write a script to read and log values of a specific row and copy them to a new sheet
I am currently working on GAS project, for the moment I have a table in a sheet and the idea is that my collaborators will be able to choose the format of the table, which column and which row they want to save. I thought about using the hiding column and row features but is it possible in my apps script to get only the data which they chose to save and not the hidden data ? Thank you for you answers
Apps Script works analogously to the Sheets UI
Explanation
If from the user interface you select the desired data by "click&drag", the hidden columns located between the start and the end column will be also selected (and copied). Instead you need to select the data of interest manually with "Ctrl" and click, see here.
How to transfer this to Apps Script?
Apps Script features the method sheet.isColumnHiddenByUser(columnPosition) (and isRowHiddenByUser, isRowHiddenByFilter etc.). You can use it to select only the ranges / the values of a datarange in columns and rows that are not hidden.
This implies the implementation of loops and conditions statements, so is not necessary an elegant solution.
I have a google spreadsheet which we use to feed inventory purchase and issue data. The only problem is my staff can manipulate purchased quantity, prices and other variables at a later date. I want that if they enter data in a cell, they cannot edit it post-midnight but I can.
Also, I have filled most of the cells with formula, for example- there is formula in A1:H999, so that when they enter data, it calculates the values in other cells, and suppose my staff has entered data till A1:H500. In this case, the script should work On A1:H500, it should not consider the whole range just because i have filled it with formula. Thanks
If you want to limit access to the script to particular hours it's fairly simple. This can be done with one function if written in a clever way or with 2 functions.
Function1 will simply lock the spreadsheet and allow only you to edit by using the protection class, then use function2 (or write function1 in a clever way to do different things depending on when it starts) that is triggered at a different time to remove that protection.
I have simple google spreadsheet with two sheets: sheet1 and sheet2. In sheet2 there are time values in column A which I am trying to copy to column A in sheet2. I wrote a script(please see link) for it but values are not the same. What class/method do I need to use in order to get same values in both sheets.
I noticed if I format column A values in sheet2 to text than I get matching values but problem is I am not allowed to that and that column must remain formatted as time.
Also, my second question(please ignore if its off topic). If I have work schedule in google sheet for 3 employees: John,Peter and Mike and they all have editing permissions. If Mike decides to use filter to filter out just his work schedule, is it possible for other two employees to have unedited sheet(as I believe Mike's actions will affect other two persons). What I mean is, is it possible to restrict one persons actions just to view he is looking at while other have unaffected version(together work schedule in this case)?
link for spreadsheet:
https://docs.google.com/spreadsheets/d/1tOtwzM0CxDHBXzC8ECeXlfaTGC4i7rH2XMYYszqRINM/edit?usp=sharing
Much appreciated.
not entirely sure what the problem is, your script is working as intended and you have the same values in sheet1 as in sheet2. The only difference is that in Sheet1 you have a date format and on sheet2 you only indicate the time. I have changed the number format in the sheet1 and as you can see it's the same.
The problem you are having is that by indicating only the time, you let the sheet assume any date. For time it's not that big a deal, but you must be sure that time formats are the same. use getNumberFormat() and setNumberFormat() (read here) to set the correct formats when copying or have the formatting set in advance
As for filtering — you can simply give them view-only access and let them use filtere views (right under "Filter"). A filter will hide information for everyone on the sheet, while a filter view will only be visible to that person. You can also pre-set filter views for them as those with edit access can save filter views.
I'm no programmer or anything of the sort. I have a Google form whose output I need to manipulate in a particular way.
The obvious stuff: When a response comes in I provide my folks at work a cell on the sheet that contains a copy of the form's output, outside of the form data area, to indicate that a particular individual has taken ownership of the response and indicate next steps--call this "spreadsheet only data". No problem adding a cell or two of course. However, as responses come in, the list will get long. So I'd like to sort based off of the response timestamp to bring current responses to the top. Again, no problem...for the form data. However if I sort all new responses to the top my spreadsheet, the "spreadsheet only data" will of course not move with the associated form data. Google forms are easy until you need to track additional data after form submission.
I have tried to abandon sorting and use a script I found to send users to the last edited field, thus providing the ease of sort without the sort problems, but that is just confusing for multiple users. Google does not provide a way to insert cells per se, but it does seem to let me get ranges and move them...as best as I can tell from pawing at the intricacies of scripting found in these forums and the older. This is beyond me if possible, but would it be possible to write a script that on form submit triggers to select a range of columns and move all of those selected cells down 1 row? I don't want to specify selected rows to be moved, just columns, given it is indeterminate how many may be present at any time.
To be clearer, I hope, the issue is that, when sorted, the "spreadsheet only" data will not move down with each new form submission, I hope to find a way to rectify that so that my folks aren't scrolling forever to get to their new response, as they would if I just kept the form data unsorted, and since multiple users make the any "go to last edited cell" solution problematic (the only other solution I can think of to make the unsorted list user friendly enough to where folks wont hate the process).
Thanks for anything anyone can do.
You can set up a filter by selecting just the header rows from the form submission table (gray box) and selecting "Filter" from the "Data" menu. This filter is also added to the "Spreadsheet Only" column as well.