I'm working on a Google Sheet to perform analysis on the cyclomatic complexities of the software under test. There's multiple projects, and I've been assigned to, and completed analysis on, one of them. I wish to extend this Spreadsheet, such that, when a user hits "Add Sheet" button, they can create a sheet ready for data insertion and analysis.
The format of the sheet
Thus far, looks like this:
...
Strategy
I know that it's possible (as I have done from experience!) to create a container-bound Google Script to create Sheets. I just don't know how to create a button to do so, let alone at the Spreadsheet level.
Business Requirements
The header row should be copied over and formatted
Custom cells (in the "Already unit-tested?" column) should be insertable, and the "FALSE" one should be inserted on row creation
formulae for average complexity,standard deviation,median complexity,number of files computations should be inserted on spreadsheet creation and update upon row creation/state change of rows
I'm not sure the way to go about all this, let alone the score of this user story.
I’d put the button on a sidebar and in that case it can be any kind of html button you wish.
I'll try insert a menu in my spreadsheet, here you'll find custom menu documentation.
just create a function like newSheet() and trigger it when button is pressed.
for the first row and the format you can use srcRange.copyTo(destRange).
use a drop-down list for the "Already unit-tested?" column using data validation
and for the formulas just type in the formula and use range.setValues().
Related
Context:
I created a Google Sheets/Forms workflow using sequential stages of Google Forms.
Form 1 (public facing) Accepts some data submitted by a public user and saves to Sheet 1.
Internal staff then contacts the submitter by telephone and conduct a more in-depth interview.
Form 2 (internally facing) is used by the interviewer to document
answers to the phone interview.
This question concerns the generation of Form 2 because I am partially pre-populating it with information from Sheet 1 (Form 1 submissions.) The way I figured out was to formulaically generate a URL with appended pre-population arguments e.g. "&entry.NNNNNN=whatever". I copied-down this formula in the last column of Sheet 1. Clicking on the cell and then the generated hyperlink successfully pre-populates Form 2 with data from the respective row of Sheet 1 as intended.
Problem: As soon as a new Form 1 submission is received, a new row is inserted into the Sheet 1 that does NOT contain the desired hyperlink formula in the last column. I would like that to be automatic so the interviewer is not responsible for performing a copy-down before every request for a Form 2.
I have pursued a couple of approaches to automating this:
One thread advised instead of copy-down, to create an arrayformula in the top cell so that it applies to the entire column including newly inserted rows as well. I tried every way I could think of but was unable to get my formula to produce a column of results with arrayformula(). If there is a way to fix this, that would be a satisfactory solution.
=HYPERLINK(CONCATENATE("https://docs.google.com/forms/d/e/XXXXXXXXXXXXXXXX/viewform?usp=pp_url&entry.251357138=",C2,"&entry.966351469=",D2,"&entry.384696201=",E2,"&entry.1366694528=",F2,"&entry.463407115=",M2,"&entry.1557144679=",B2,if(P2,"&entry.1777888516=Email",""),if(O2,"&entry.1777888516=Phone",""),if(H2,"&entry.2110474669=Individual+(Adult)",""),if(I2,"&entry.2110474669=Individual+(Under+18,+Minor)",""),if(J2,"&entry.2110474669=Couple",""),if(K2,"&entry.2110474669=Family",""),if(L2,"&entry.2110474669=Group",""),if(R2,"&entry.1892971721=San+Jose",""),if(S2,"&entry.1892971721=Sunnyvale","")), "Complete Intake")
I tried to create a ModalDialogue and display a script generated hyperlink in it. I used this approach found in this forum. But this did not open any dialog at all and threw no errors (even after hyperlink was removed.) There was no indication of pop-up blocking. Other parts of my script use Browser.msgBox without any pop-up troubles, but I don't think that will pass a hyperlink.
var htmlOutput = HtmlService
.createHtmlOutput('Click to open and prefill intake interview form.')
.setWidth(250) //optional
.setHeight(50); //optional
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Ready to fill intake interview form:');
Using onFormSubmit() and scripting a copydown after a new row has been inserted. But I have been unable to figure out how to identify which row was inserted into Sheet 1. I see some people using lastRow(), but it isn't always inserted into the last row - typically it goes in the middle somewhere.
Request:
Help getting arrayformula to work in my case.
Or help getting ModalDialog to display a script generated hyperlink.
Or help on how to identify the row the Form submission inserted. Or do I just need to make sure the table remains sorted by TimeStamp and then I can use lastrow()?
Suggestion for a cleaner approach to get to the same place (generating a prepopulated Form from a row of data in Sheet 1.)
Thank you for illuminating a path forward.
You should consider using ArrayForumlas to automatically copy down the formula to other rows that have a value in the first column.
Put this formular in row 2 of the column that has the Google Form links.
=ARRAYFORMULA(
IF(ISTEXT(A2:A),
HYPERLINK(
CONCATENATE(
"https://docs.google.com/forms/d/e/XXXXXXXXXXXXXXXX/viewform?usp=pp_url&entry.251357138=",C2:C,"&entry.966351469=",D2:D
)),""))
I wrote a tutorial on copying formulas if you need more examples.
It turned out I was able to successfully employ approach 2, the modalDialog. For some reason no dialog was appearing when I first attempted so I didn't know if there was something fundamental wrong with this approach. I tried again and it worked as shown below so I suppose I just had some typos. Adding target="_blank" was helpful so as to open in a new tab.
var htmlOutput = HtmlService
.createHtmlOutput('Click to open and prefill intake interview form.')
.setWidth(250) //optional
.setHeight(50); //optional
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Ready to fill intake interview form:');
I made a form with multiple conditional paths and my response sheet is ungodly I could really use some help.
The way I set up the form has a total of 19 sections
Location Dropdown (we have 3)> Machine dropdown (a total of 15)> A Machine Specific measurement section and Submit.
I split the Measurements sections by machine because, I was hoping I could have each section record numbers into separate sheets. This way I could keep each Machine's data on its own google sheet.
So logically I am trying to get MachineX measurements to record sheet X but, Get Machine Y to record In Sheet Y. Is what I'm looking for feasible/ even possible?
I know I can try and organize the form responses into the sheets manually, but I am trying my best to avoid that, cause its gonna take a lot of time out of the week.
Maybe there is a way to organize the form response sheet to filter the data into their appropriate sheets.
I am out of my depth and could really use some help.
You can set up a linked Sheet to the Form and then an Apps Script function that gets the data and prints it into the Sheet.
First you have to create an Installable trigger: On form submit so every time the form is submitted the Sheet will be updated
Once you have your trigger set up, you have to write the function.
I would suggest you to create variables for each sheet you want your data in.
You can select the sheet by name like: sheet.getSheetByName("MachineX")
I recommend setting up the questions in an order that allows you to say:
From question 1 to 6 -> go to "MachineX"
From question 7 to 19 -> go to "MachineY"
Now you have to iterate over the answers and get the latest responses:
- If you just want the latest response to the form you could use something like:
for (var i = formResponses.length - 1; i < formResponses.length; i++)
I have a running parts order list that several people use. I am trying to have the top row be a form so the user enters Qty, Part #, and Notes and presses Enter. I want it to add a row to the top of the sheet below the headers and maintain the table structure so we can filter.
Instead of using the top row, go to Tools then create form. This will make it easier to input stuff. Also no one can muck up your sheet.
Also I would read what you can post here :) I like to be friendly so I thought I'd put an answer
You should read about Google Apps Script. GAS is the easiest way to read/write data in Google Spreadsheet/Docs/Forms.
So as far as I understand from your question, you need to insert a row in Google Spreadsheet below the header directly as soon as the forms.
Step 1: Open the spreadsheet using openById(id)
Step 2: Get the worksheet in which you want to save your Google Forms data using getSheetByName(name)
Step 3: Insert row before specified position using insertRowBefore(beforePosition)
So final code should look like this.
var spreadsheet = SpreadsheetApp.openById("1BZuYFCnN_g9vn5crxbPeYlhUKwH6N3u0uT8LCmm-neM");
var sheet = spreadsheet.getSheetByName("Nov-2017");
sheet.insertRowsBefore(2);
The code above will insert only one row below spreadsheet headers. There is an alternative -> insertRowsBefore(beforePosition, howMany) if you want to insert multiple rows at a specified position.
Try this and let me know if you find any difficulties. Hope this is what you're looking for.
I have a google form response sheet and I have created a separate tab for doing analysis on an individual response. Basically filling out a table which is then used to generate graphs and charts. Each time I need to do analysis on a single response, I have to change the formula to look at the specific response and then drag the formula down to update the whole table and which then creates a column chart in a separate sheet.
My question is- Is there any way I can simply select the response (like a button in the google chart dashboard sheet) which then looks at the response in the response sheet and updates the table in the separate sheet to give the graph accordingly?
I have not used any app script so far in my sheet for the dashboard? It is just a simple data validation method looking at the values from other sheet and gives the graph. Not sure if app script is the solution or any other solutions to work around this.
Help!!
Table to fill from google form:
Google Chart Dashboard:
You could use a query or "if" formulas to do what you are describing. Your query or if statement should point to a cell(s) which is have drop-down data validation lists, which when changed then alter your table, which in turn changes the graphs.
Example 1:
=query(Sheet!A:C,"SELECT A WHERE B ='"&D1&"'",0)
This query looks at the cell D1 and altered depending on its contents.
Example 2:
=if(D1="SOMETHING","DOSOMETHING","ORDOSOMETHINGELSE)
In this statement again D1 could be a cell that contains a drop-down list of variable data validation items.
Hope this helps
How to reference the same (row,column) on the different tab in the same google spreadsheet document?
So, I want to do something like this:
=SOME_FORMULA('First tab'!(ADDRESS(ROW(),COLUMN()))). This doesn't work.
If the formula isn't apsolutly referenced, entries of Google Forms questionnaire change the reference and mess up the formula. (the formula that looked at row number 5 after insert looks at row number 6) I can't use apsolute referencing ($A$1) because I have to enter it manually.
Can I change the reference on multiple cells? (for one I can use cmd + f4)
I had that annoying reference problem too. If I understand correctly you are trying to get the information on some cells, but every time someone sends information to the spreadsheet by filling up a Form, that reference moves down a row.
The best solution I came up with was to create a new SpreadSheet and import all the information with this:
=importrange("spreadsheet-key","Form Responses!A1:B2107")
That function updates the info in realtime, so you can do all the processing on the new spreadsheet.
Hope this helps.
Do not quite understand what you need. Need to reference a cell in another sheet given coordinates on the current cell where it is located?
If so, the following formula can be useful:
=INDIRECT("First tab!"&ADDRESS(ROW(), COLUMN()))