In this case, I don't have a code or screenshots to share because I honestly don't know how to even start it :)
We have a spreadsheet (Google Sheets) which have numerous scripts built into it. They run mainly based on form submission and don't require any further confirmation after a form is submitted. For this new form we wish to implement, we would like to script to run only after a user has confirmed via email. Here's the rundown:
User A (normally from the administration department) will input data into a form.
Once form is submitted, this data will be sent to another user (User B) for confirmation. We would like this process to happen over email, and not directly via Google Sheets prompt.
Once User B confirmed data is good, a script will run to compile the data and perform several actions on it.
No problem to send an email via script but how do we include a confirmation button/link to it and how do we capture this clink to continue the compiling of this data?
Thanks :)
User A Enters data into Form and Presses Submit
FormSubmit Script recovers data and sends email to user B
User B reviews data and Presses a link on the email which sends a request via a web app to complete the transaction at a later time.
You can probably customize the webapp link with query string parameters so that the transaction can be completed without any further interaction but it will probably take a couple of days of programming to complete and test the job.
Related
I would like to use Google Forms in my webapp to run quizzes.
The Google Form is created.
I use the pre-fill option to get a URL.
From my web app I create an iframe and pass the URL (different for each user) by passing the user-id to the form.
User now fills the form and submits.
The data is stored in a spreadsheet.
Earlier I publish the spreadsheet (thereby making it public).
I can now access the spreadsheet data and update my local database.
So currently, when the user submits (from within Google Form) there is no way my web app knows about it. (I have browsed the internet for solutions but did not find any).
Is there a way to get around this?
Currently, at some "stage" in the web app, I check if the user form data is available in the database. If not, I check the spreadsheet for that user data. If found, update the webapp database. So in that sense the webapp uses a pull-feature to check for updates.
Thanks
I see that you want to know when a new Form response has been uploaded. If my understanding of the question is correct, then you could use a simple .onEdit() trigger in the response Sheet. As an alternative, you could use a FormResponse.submit() installable trigger that fires at each response. Please keep in mind that triggers are limited to form uploads that don't fire from API requests and script executions, as detailed here. Please, don't hesitate to ask for further clarification.
UPDATE
Based on your last comment I get that your priority is to see the response Sheet updated in real time. If my understanding of the issue is correct, then you can show the responses Sheet directly in a webapp inside an iframe. Please, ask me any question if you have doubts about this approach.
So, we have this task where we have a Google Form where a user submits data as a sign up for a mentoring service that gets passed on to a Spreadsheet and the user gets an e-mail as a sort of like confirmation that the sign-up did indeed happen. During this, the mentor that the user specified also gets an e-mail with some of the information that the user has sent, and a link that redirects them to a pre-filled Google Form that contains some of the information that the user submitted, and a drop-down question that basically serves as an attendance check.
Now, all of that mentioned already works. The problem is, the way it is set-up is that there are 2 Google Forms that direct to the same spreadsheet, just in different tabs. If I try to use OnFormSubmit as a trigger for the functions that allows for the emails to be sent, what happens is both OnFormSubmit triggers occur at the same time. I've seen multiple solutions to this problem here but none of them seem to work for me. Is there a way to manually script the OnFormSubmit function to let it work only when a specific form is passed?
I want to use Google Form as a contact form on a website, and email the contents of the form (not just a notification) to a specified address.
I created a Google Form, embedded it on a website to use as a contact form for enquiries. Then created a Sheet to pull in the data from the Form. After that I created a Trigger for onFormSubmission which runs the following:
/**
* #OnlyCurrentDoc
*/
function onFormSubmission (e) {
var values = e.namedValues;
var htmlBody ='<ul>';
for (Key in values) {
var label = Key;
var data = values[Key];
htmlBody += '<li>' + label + ": " + data + '</li>';
Logger.log(label + ": " + data);
};
htmlBody += '</ul>';
GmailApp.sendEmail('me#gmail.com', 'Web Form Enquiry', '', {htmlBody:htmlBody})
}
Running this brings up a dialogue stating:
Authorization required.
'Send email' needs your permission to access your data on Google
Review Permissions or Cancel
['Send email' is my 'App' in G Suite]
Clicking Review Permissions opens a popup asking to choose an account to continue. Clicking on the account (the same account I'm logged in with and have created the form, etc with) brings up:
This app isn't verified. This app hasn't been verified by Google yet. Only proceed if you know and trust the developer.
Advanced or Back to safety
Clicking Advanced:
Google hasn't reviewed this app yet and can't confirm it's authentic. Unverified apps may pose a threat to your personal data.
Go to 'Send email' (unsafe)
It then states:
'Send email' wants to access your Google account
This will allow 'Send email' to Read, compose, send and permanently delete all your email from Gmail
Connect to an external service (Create a network connection to any external service (e.g. to read or write data)
Make sure that you trust Send emails
You may be sharing sensitive info with this site or app. Find out how Send emails will handle your data by reviewing its terms of service and privacy policies. You can always see or remove access in your Google Account.
Find out about the risks
Cancel or Allow
So, for testing purposes I clicked Allow. And it all worked beautifully! And I made the form responsive, and then I remembered I had to go back and review the permissions. After 4 hours I got lost down the rabbit hole, and crawled my way back up to here in confusion. So my questions are:
Do I need to implement OAuth?
Does Google need to verify the app?
If yes to 2, does this take weeks? (If yes, probably need to abandon this solution)
If I give the app 'permissive permissions' (as I did for testing) is there any security risk?
If I give the app 'permissive permissions' is Google going to review it and decide to stop it running?
The only reason I can imagine that OAuth is needed is that data is being taken from Sheets, an email is being created and the data is being passed to that. Is it because of the data being passed to a different 'service' than collected it? Or because a different service is instructing the creation of an email? (Or both?)
If OAuth is implemented does this mean that users will be asked to verify? Obviously, they will not require to be logged in to use a contact form on a website.
Is it possible to restrict the permissions eg to only compose emails, rather than have the ability to delete any or all emails in the account (manifest?)
Would it make any difference if I skipped the spreadsheet ie Form to email? (Can't see how, but asking just in case.)
This is my first time using these services, so hopefully, I've explained it ok.
Any advice gratefully received!
I want to use Google Form as a contact form on a website, and email the contents of the form (not just a notification) to a specified address.
Do I need to implement OAuth?
What you're doing is already OAuth flow. But it's managed by apps script. So, No.
Does Google need to verify the app?
Not for your use case.
If yes to 2, does this take weeks? (If yes, probably need to abandon this solution)
Maybe more
If I give the app 'permissive permissions' (as I did for testing) is there any security risk?
Anyone with access to your script(by implication, anyone with edit access to your spreadsheet) can change the script to send email from your account to any other website or Read or delete your email. So, Avoid providing edit permission to your Spreadsheet or script.
If I give the app 'permissive permissions' is Google going to review it and decide to stop it running?
Not if you're the only user.
The only reason I can imagine that OAuth is needed is that data is being taken from Sheets, an email is being created and the data is being passed to that. Is it because of the data being passed to a different 'service' than collected it? Or because a different service is instructing the creation of an email? (Or both?)
Yes.
If OAuth is implemented does this mean that users will be asked to verify? Obviously, they will not require to be logged in to use a contact form on a website.
You are the owner of the email, sheet and the form responses. Only you need to authorize the app/script to act on your behalf to do certain jobs like copy/paste.
Is it possible to restrict the permissions eg to only compose emails, rather than have the ability to delete any or all emails in the account
Yes.
You can use MailApp instead of GmailApp
OR Limit the scopes in apps script manifest file:
https://www.googleapis.com/auth/gmail.send
Would it make any difference if I skipped the spreadsheet ie Form to email? (Can't see how, but asking just in case.)
Reducing the number of hops it takes for the script flow is good for security. But doesn't make much difference in terms of oauth flow/permissions requested. You can use the formsubmission trigger in the form itself. Note however that you need to redesign the script according to the event object provided on formsubmit to the form. This is different from the event object provided to the spreadsheet onformsubmit.
I have created a Form in HTML UI Service , its working fine when i submit the data. But when ever, any other user from the domain submits a record it is not recorded .I have changed the permission of backend spreadsheet to 'People who have the link can view'. Still the response is not recorded when a different user submits . Please assist possible correction
Since you set the permission of the spreadsheet to "anyone with the link can view" and that your app is running as the "user accessing the app" the app can't write anything in the spreadsheet. That's how it works.
If you don't want to change the SS authorizations you'll have to use some workaround to write data to this SS.
One possible way is to use a second app that runs as a service and that receives data from your webapp and write it back to the SS. This service would be running as "you" of course.
If you don't know how to go through this feel free to ask (and explain how much data you have to write) and I could show an example.
Using Google Apps for business, I have a form that company users access on a google site. The users completes the form and submits. onSubmit, a script runs, collects the data and puts into a PDF and sends an email to me for review.
Right now when the email is sent, it comes to my inbox as me sending to me. I'd like to have it send as the user submitting the form. Can anyone point me in the direction to send as the user submitting the form.
permissions are set as followed:
The spreadsheet sharing option has anyone at company can find / view.
It's deployed as "execute the apps as:" User accessing the web app. And anyone at the company can access the app.
thoughts?
You can replace the form with an HtmlService or UiApp version that runs as the user, and then the email will come from them.
Assuming your are using Google Forms, I don't believe the function/script being run onSubmit is being run by the user who fills out the form, its being run by the owner of the script (you). As #Corey G stated, you can use HtmlService or UIApp to create a form, but takes much more time to create the form itself.