How can I link to Google Sheet from Google Form? (Exploring Make a Copy feature, but I need it to be shared with the original owner) - google-sheets

I'm posting here because I'm hoping someone can help me edit the link to a google sheet. I haven't been able to find the answer online, but I'm hoping maybe someone understands how the link works better than I and can give me an answer.
I've been tasked with updating the application for funding (from a non-profit) to include a budget category. The application is in Google Forms, but there's no way to insert a table into the form for an applicant to fill out. I created the budget outline in a Google Sheet, but now I'm trying to find the best solution to create an individual link within the form that will lead them to the budget document. Essentially, I'm hoping the applicant can fill out the form, and when they reach the section about their budget, I want them to click the link to the google sheet, have it make a copy, but have the copy be shared with the organization's google account so we can see it when they submit their application.
I've experiment with the forced copy feature (editing the shared link by google), but when I test it from a different google account than the owner, it tells me I have to request permission. The share settings are set to allow anyone with the link to access, so I don't understand why it's asking me to request permission when I open the force copy link. This isn't going to work because the applicants need to access it when applying, and we can't have them waiting for us to accept the request every time.
I'm sure there could be a few solutions, so I'm open to any advice. The only other solution I can possibly think of is creating individual links for each applicant, if there's a way to automate that?
I recognize there could be a solution where I ask the applicant to download the file and re-upload, or share it themselves, but our applicants are not native english speakers and they are often non very comfortable with technology, so I want to automate the process as much as possible.
To summarize: The applicant should be able to
Fill out the google form
Receive an individual copy of the budget document (from google sheets) to fill out.
The budget document must be shared with the original owner so we can see it and see how it relates to the rest of their application.
Thank you for your consideration!

A solution for your use-case would be to make use of Apps Script.
Apps Script is a powerful development platform which can be used to build web apps and automate tasks. What makes it special is the fact that it is easy to use and to create applications that integrate with G Suite.
Taking this into account, you can create a script which will create a copy of the document whenever a new form submission is made and add the permissions needed for the user. Essentially, you will be the one owning the copy of the sheet as well and the candidates will have edit permissions.
Therefore, the script will end up looking something similar to this:
Code
function onFormSubmit() {
let sheetId = 'ORIGINAL_SPREADSHEET_ID';
let form = FormApp.getActiveForm();
let responses = form.getResponses();
let n = responses.length;
let currentUser = form.getResponse(responses[n-1].getId()).getRespondentEmail();
let newSpreadsheet = SpreadsheetApp.openById(sheetId).copy("Sheet copy for " + currentUser);
let newSpreadsheetId = newSpreadsheet.getId();
DriveApp.getFileById(newSpreadsheetId).addEditor(currentUser);
}
Explanation
The above snippet makes use of the Apps Script's onFormSubmit installable trigger. Basically, whenever a new form submission is sent, the code above will run. The code will retrieve the last response which was submitted and get the user's email address by making use of the getRespondentEmail method. Afterwards, a copy of the original spreadsheet will get created and shared with the editor permission with the user who just submitted the form. Adding the permission is done by making use of the addEditor method from the DriveApp parent class. As for the user accessing the copy of the spreadsheet, this is easily done as the user will end up receiving an email telling them that a spreadsheet has been shared with them.
Setup
You will have to have the Collect emails option checked for the form;
Open the three dots icon and click on Script Editor;
Once you open the script editor, input the code from above and do not forget to modify the sheetId such that it matches the id of your original spreadsheet that you want to share.
Install the onFormSubmit trigger by going to the Triggers page and create a new trigger with the following options:
Send the URL form to the candidates and wait for submission to be sent.
Reference
Google Apps Script;
Apps Script Installable Triggers;
Apps Script SpreadsheetApp Class;
Apps Script FormApp Class;
Apps Script DriveApp Class.

Related

data entry form in google sheet for multiple users not working when accessed simultaneously

I've created form in google sheet, so that multiple users can add data, modify & delete.
However, it is not working properly when multiple users are working on it simultaneously.
For an example, two people are working on the sheet. User A and User B. If user A is typing something user B is also able to see and user B will be able to enter the detail, but it will change the details which are being entered by user A. Technically same sheet is opened for both the users and details keeps on changing what users are changing.
Ideally, if user A is entering some details user B should not be able to see it and form should be blank or unique for user B, so that both the data won't clash. I want it to be like the way google form is there wherein form will be blank when any user is opening it. (I have tried google form for my work, but as there are too many drop downs google form takes time to load and work gets slow that the reason I am trying to find the option in google sheet).
google sheet link
Above is the google sheet which you can open and check the form and coding. Also, please test it with a different id to test for multiple users.
Let me know if there is any workaround for this. Also, let me know if you need any other details.
Answer:
This just isn't possible. Sheets is meant to be a collaborative tool; what's edited by one person will always show up for others. You need to use a different tool, for example like a Google form for data entry, but having data not being edited in other open versions is just not workaroundable.

I want to check information contained in a Google sheet, as the respondent is completing a form

We are using forms to allow people (staff) to book equipment out of a store, self service. We record who took what, and when they book it back in. They are asked if the tool condition is good, and if not, are taken to another part of the form to select a fault category. I record this information in the linked sheet.
so my question is can I read the information in the "fault" column of the linked sheet for that item ID, and generate a message to the form user such as "This item has been reported as faulty - please do not use it!" etc etc
If I could script the form so that it scans the linked sheet in the relevant column / row for the item they are trying to scan out, and then warn them that is has an entry in the "Fault" column, that would be perfect. Ideally as they scan the barcode of the item they are taking, before submitting the form, but after submit would be fine too.
I have searched widely and not yet found a solution
Since the only triggers which are available for Forms are the onOpen, onInstall and onFormSubmit, this cannot be done directly.
Possible solutions
1. You can develop your own form
This can be done by using Apps Script & HTML & JavaScript and creating your own Sheets add-on which will interract with the sheet you have in order to check the status of the tool.
2. You can programmatically update either the question name or the form description in order to include the accepted values for the question regarding the tools.
This can be done by creating a script attached to the sheet and using the onEdit(). So whenever a change is made in the tools section for example, this new data can be gathered as a string and update the fields to contain the updated values for the tools.
Reference
Apps Script Simple Triggers;
Extending G Suite with Add-ons.

Sharing a created Google form with linked sheet for others to use

I have created several systems with Google Forms (and linked sheets) to log services provided and timekeeping. I would like to share these systems with other people to use as a template for their own data. Is there a way to easily do this keeping my formula's intact?
Successfully: I have found a way to share the form only as a template by copying the URL into an emailed hyperlink changing the ending from edit to copy.
Cumbersome but ok Migrant Service Log: This method does not seem to work entirely for spreadsheets. It still asks me to give them access to the original document. I can set access on the original to view only and limit the time to one day.
Unsuccessful Clock In/Out: The new "copy" of the spreadsheet is not automatically linked with new "copy" of the Forms so it does not update when a new response is added. I must link it in form. This becomes more of an issue with my sheets that have formulas based on these responses. It is now necessary for each new user to manually link and rename the sheets to make them function correctly.
Clock In/Out System (attendance purposes)
Clock In Form
Clock Out Form
MSA Sheet
Attendance Office Sheet
Migrant Service Log (team communication purposes)
Migrant Service Log Form
Migrant Service Log Sheet
I would like for them to all be user-friendly and easily shared while keeping everything confidential to the user.
if you want to keep your formulas as a secret you can set up the 2nd spreadsheet and use IMPORTRANGE formula to get data over and then just simply link the 2nd spreadsheet somewhere on the end of the form.

Getting Files From Another User's Folder

So I've read the documentation for the dropbox api, and its quite rough around the edges, and Im not sure that I can do this. Basically what I want to do is make my app create a folder, give the user the link so that they can give it to other users. After those users have that link, they can paste it into the app and it will let them see whats in the folder. They don't even need to be able to see it, the app just needs to be able to download files from the folder. Its kinda exactly what a shared link would do in the normal dropbox. Is this at all possible? And if so, how would one go about doing this?
This certainly sounds possible, but you would probably need your own server-side component. The basic idea as I see it:
user A links the app to their Dropbox account
the app has the user pick a folder
the app generates its own link for that folder and supplies it to user A
user A supplies the link to user B
user B supplies the link to the app
the app looks up user A via the link, and uses /metadata or /delta to list files from user A's account, and then /files (GET) to serve file content to user B (from user A's account).
The server-side component is important in order to avoid exposing user A's access token to any other user.
This would be much easier, and wouldn't require a server-side component, if Dropbox offered an API for Dropbox shared links themselves, since you could then just use /shares to get one and pass that around directly. It doesn't though, so I'll pass this along as a request.

How can I access the name of the user running a script embedded in a shared spreadsheet?

I have a Google Spreadsheet containing a script that I wrote. The script updates a per-person sheet named after the logged in user, or creates a new one if it's not there yet.
I shared it in "can edit" mode with other people, expecting the code accessing the user name to work as it did in my case, but apparently it doesn't.
Google Apps Script seems to contain three ways to get the name of the current user:
Session.getActiveUser()
Session.getEffectiveUser()
Session.getUser()
and all of them return the empty string when I'm not the user running the script.
(Btw I'm having a hard time to tell the difference between them...)
Considering that I'm sharing this spreadsheet in read/write mode, I would be a bit surprised if this was an intended security method... it's not like I don't know the emails of the people accessing the spreadsheet I've explicitly shared with them... Plus, Google is asking for permission anyway, couldn't it ask for permission to access the user name as well??
Is there a way around this?
Is there a way around this?
These methods only work if you're using a Google Apps account and you're on the same domain as the user. If not, then there's no way to get the user id. AFAIK Google removed this feature completely for regular accounts. You may try to argue with them opening an issue here.

Resources