Am stuck. Have looked high and low for a method to pull multiple edited values from a google spreadsheet row. Have trawled through the google App Script list of commands. Nothing found.
A form is submitted to a google sheet that can change multiple columns per row per event.
Basically, I have an onChange(e) script that reads the changed row. It is installed and working. I can pull from the changed row single values, row and column details etc. However, despite using a variety of combinations I cannot pull a multiple row changes from a form that updates the row with multiple column changes per row. I have tried array variables all to no avail. It still only pulls a single column change per row. Have also tried A1Notation again to no avail.
Is there any way to pull changes in columns 3, 9, 17 for example?
I am happy to work through the problem if someone can just let me know a single line function command or a way that it is done. Is there something like columnChanges = [ e.source.getXXXXXX().getYYYYYY() ]; that will allow me to pull array variables that have the changed values?
Any help appreciated but I am now desperately stuck with this and prefer to avoid keeping duplicate spreadsheet and then cross checking what has changed between the two.
If you are using a Google Form to submit values into your spreadsheet, then you could use a Form submit trigger instead, and you can easily get all changes out from it.
Also, depending on your script, you might actually be only listening for one of the Edit events, which also triggers Change.
Share your script to get more specific help.
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'm currently working on a Spreadsheet, and I'm up to the point of creating either a button or checkbox to SELECT and COPY a row to another sheet as part of an efficient archiving system. For e.g. the user will select their row, click the button and the row will be copied in the mentioned sheet. I'm still quite new to scripting in Google Spreadsheets as a whole. I personally wanted to head into the direction of using a button, but I'm open to suggestions.
Thank you all!
I think that works (you will be assigning a script/function to an image you upload, and then in the function use .getRow() on the active cell). Here is some advice that could save you some time. For your use case, instead of using a button, consider using the QUERY command:
You have a table in "sheet1" with some columns:
In that table you have an IMPORT column. You can use data validation on that column so that it is a Yes/No dropdown as well.
In a separate sheet, you write this which picks out all the rows with "Y":
=query(sheet1!A2:D1000,"select A,B,C where D='Y'",0)
And that will output this (minus the headings, which you can customize based on the last argument of the QUERY command):
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.
Here is my issue. I have a spreadsheet with multiple sheets, and each sheet has about 300-500 rows. I am using ScriptDb to store the data for each sheet.
What I am currently doing is calling a custom function in 300-500 cells in each sheet to populate certain cells with data, and what happens is that some will populate and the rest will error out saying i've queried the database too many times in a short period. Obviously having to query the database for each cell isn't the best solution.
How would I go about querying all the data for the current sheet and then having that data available to grab for each cell. What I've read is that you can't really have "global" variables in GAS, but have to use things such as CacheService or ScriptDB, which is what i'm trying to do. I'm just querying it too much.
Is there some way to populate all the cells from 1 function call instead of 1 call for each cell? What am I missing or what other solutions are there?
Just realized a similar question was asked earlier today: Google Spreadsheet Script invoked too many times per second for this Google user account
Yes its possible. Simply return an array from your function. It will work like an arrayformula.
Of course your cells would need to be contiguous.
I have a two-part question about master/child relationships in workbooks. I have beginner experience with writing code for excel & google spreadsheets so any extra detail would be truly appreciated.
Here is what I'm trying to achieve:
I want to make a google form to collect a set of data for (potentially 100's of people). The option to make changes to the form after submission will be enabled, so the data flow will be pretty dynamic. I've gotten as far as setting this up and creating the master spreadsheet where I can view all of the responses. But there's too much information in one spreadsheet and I'd like to make some child-workbooks to simplify the viewable data for various needs. So here are my questions:
1) How would I write the script to create a child worksheet from the master worksheet with these conditions: on run create a new worksheet called i.e "Child 1-Basic Info", delete all the columns and shift left with the exception of the ones I explicitly want to keep (based on the cell value) i.e "Name", "Age" & "Interests". Bear in mind I would want to eventually create multiple children workbooks, but basically do the same job each time. Just different column parameters i.e "Child 2-Education Info".
2) Along with this, I want to make sure that these children will be automatically updated every time someone submits a new response from my form or updates one they have already submitted. Essentially, the goal is to have any changes in the master ripple into all of the children. Also keep in mind that every time someone submits a new form, the row numbers will change. So the children will need to also recognize this change and update accordingly.
Thank you all in advanced!
With the QUERY() function, you can have secondary sheets that will dynamically update, with no need to use scripts at all. See more here.
Here's an example, a spreadsheet with rows of form-submitted data:
On a secondary sheet in the same spreadsheet, cell A1 contains a query formula that selects only the columns you asked for, "Name, Age, and Interests".
Every new form submission or update will result in recalculation of the query, so it will be kept up-to-date with no further intervention.