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
Related
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.
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 have a form in Django that adds users to a mySQL database. However, the user will have to add tons of users, and some information will be copy and pasted. So I was thinking if there is a way to have a spreadsheet like form, where the column titles would be the fields that will be added to the database (such as id, firstname, lastname, etc...) and every row would be an information associated with one user. When you click the submit button, it will add each row to the database. Again, the user will need to have the ability to copy a row and paste it to another row. Thanks!
Probably the easiest thing is to get the users to use an actual spreadsheet and save it as CSV, then provide a facility to upload and process that CSV.
I'm writing a script for an insurance agency that will work like this:
When an employee makes a sale, they enter information about each policy they sold (name, policy number, etc.) in their own Google Spreadsheet, one policy per row.
Script takes spreadsheets from every employee as input and writes them to a table in database.
When policies get paid, they get written to a separate table.
I use an OUTER JOIN to see which employee sold each paid policy.
The issue I'm having is that in step 2, I don't want to write policies to the database that have already been written (i.e. because they were there last time I ran the script). I can think of a few ways to solve this...
Clear the table every time I run the script, so it's being written fresh every time.
Loop through and check if a given policy is already in the database before writing it to DB.
Add a boolean column called "copied to DB", when adding rows to DB check if "copied to DB" is equal to "Yes": if true, don't write the row to DB; if false, change "copied to DB" to yes and write the row to the DB.
I think any of the above methods would work, but they all seem pretty inefficient. Is there anything in SQL or Google Apps Script that would do this more efficiently and minimize database writes?
Currently, the way I'm doing step 2 is I'm copying all the employee sheets to a single "master sheet" that contains all the employees policies, and every time I run the script I clear the master spreadsheet and then copy all the data in, so there are no duplicate rows. This is basically equivalent to method #1 above, but again, it seems like there should be a better way to do this than clearing the spreadsheet every time. (And I'd rather use a database table than writing all the data to a spreadsheet.)
Thank you!
Its easy if the spreadsheet rows are 1) always appended, 2) never changed or deleted.
Loop for each spreadsheet:
Remember in a script property the last row written to the db (one property per spreadsheet, base the script property name on the spreadsheet id).
Start from the row after that last one, write to db and afterwards write the property.
Make your db row primary key something like 'spreadsheet id + row number', and use 'insert or ignore' or equivalent. This is a must for integrity as a script could fail after a db write but before writing the script property for that spreadsheet.
I have a popular chrome extension that does this well for thousands of users.
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.