Linking google forms to master & children spreadsheets with automatic updates - google-apps-script

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.

Related

Data entry form responses directly to a template

I have created a data entry form in Google Sheets, and would now like the data to be placed in my templates cells automatically. The user fills out a form, and ideally the answers would fill out the template and execute the calculations automatically. Is this possible?
My key questions are to
create a new tab with a template for each new data entry (results in a row in the data tab)
place entry-values to the tab to execute the calculations
I can also create many duplicate tabs of the template and place each answer to the specific cell manually, but I don't know how many entries there will be.
I have tried to create a new tab with new entries, but the tab is missing my template. I tried to link answers to specific cells, but did not know how.
If I understood correctly, you are using Google Forms to collect data and store the responses in a Google Sheet.
If that is correct, the best way to manage that input data adding calculations or other extra fields is to use a different tab.
F.e, if your form is collecting responses in tab "Form A", then you need to
Create another tab (let's say "curated A responses")
Import the data from "Form A" into the second tab
Add more fields, calculations, charts... whatever you need.
The simplest way to perform step 2 y using ='Form A'!A:A for column A and so on.
You write that into the first column of the second tab and it will populate existing and new values automatically.

Google Sheets: Automatic add rows in multiple sheets based on Master Sheet

I have a Google Sheet with multiple tabs. The first one is the Master Sheet where I have some basic location info. In the other sheets I'm transferring those basic info through "Importrange" so I have some columns dynamically changing and some that are static and the users are able to update. Although, if I add a row in between my data at the Master Sheet it will only change the dynamic columns (updated from importrange) but the rest columns won't change- which will mess with the updates.
Is there any way/ script where I can add rows in the other sheets automatically when a row is added in the master one?
You are describing a row misalignment issue. See Lance's thorough treatment of the issue and how it can be dealt with in some cases. It is a lengthy read, and too long to repeat here.
If you are simply trying to let each user to edit "their" data, you can also keep all the data in the master sheet and use filter views to decide which rows to show at a time. This feature lets multiple simultaneous users sort, filter and edit a sheet without disturbing each other.
For additional ease of use, you can insert links in the frozen section of the sheet to easily switch between filter views, instead of having to go to Data > Filter views to switch. See the Filter views example spreadsheet for an illustration.

How do I lock a cell's copied value determined by a formula and prevent it from updating when the referenced cell in formula does?

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

Making updates to google forms

At present this is a hypothetical question and I haven't begun writing the code for this, mainly because I'm not sure if it is possible to achieve what I need to in Google Forms.
We have a employee contact form that is completed when they join the organisation, obviously people go through changes in life and either get a new mobile or change address, when this happens they change their contact details via a Google form, this adds a new row of data to the responses spreadsheet meaning that we have a duplicate entry for the same employee.
What I want to be able to do, is have the sheet look for duplicate data and overwrite the fields that have changed. I am fairly confident that this is possible, however, I am struggling with the logic.
If it is possible? Could you provide a hint as to how this might work.
It is possible to look for duplicates in a spreadsheet and delete them, however if you do it in the destination spreadsheet of a Google Form - the deleted duplicates will come back at every update.
So you need a workaround:
Create a new spreadsheet (slave) that will be synchronized with the destination spreadsheet (master) on every form submit
The form data from each form submit will be checked for duplicates before being written into the slave
You need a unique identifier, e.g. employee number
You can check either an entry with this identifier already exists in the slave, e.g. with indexOf()
If the identifier does not exist yet - append the new data to the last row of the slave
If the identifier exists already - find the row containing it and overwrite it with new data

Google Form Event / Spreadsheet Cell Move Query

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.